ReverseWords1 - for(int wplace= word.length-1 wplace>=0...

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

View Full Document Right Arrow Icon
public class ReverseWords1{ public static void main(String[] args){ String line = IO.readString(); line= line + " "; String result = " "; while(line.length()> 0){ int spPlace= line.indexOf(' '); String word= line.substring(0, spPlace);
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.outputStringAnswer(result); } }...
View Full Document

This note was uploaded on 07/12/2009 for the course CS 111 taught by Professor Hari during the Fall '08 term at Rutgers.

Ask a homework question - tutors are online