ReverseWords

ReverseWords - for (int wPlace = word.length()-1; wPlace...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
public class ReverseWords{ public static void main(String[] args){ System.out.println("Enter string:"); String line = IO.readString(); String result = ""; int spPlace = line.indexOf(" "); String word = line.substring(0,spPlace); while (line.length() > 0) {
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: for (int wPlace = word.length()-1; wPlace >= 0; wPlace--) { result = result + word.substring(wPlace, wPlace+1); } result = result + " "; line = line.substring(spPlace+1); } IO.printString(result); } }...
View Full Document

Ask a homework question - tutors are online