Hey...this is my code to reverse each word of the string input!!
At line 12 it says 'illegal start of expression'....any idea how to troubleshoot this ??
//Reverse each word of the sentence import java.io.*; class rev_word { public static void main (String args[ ])throws IOException { BufferedReader br = new BufferedReader (new InputStreamReader (System.in)); String S = br.readLine(); S=S+"";int k=0; String word=""; for (int i=0; i<S.length();i++) { if (S.charAt(i) == ' ')) // <-- error shown at this line 'illegal start of expression' { word=S.substring (k, i); k= i+1; for (int j=word.length();j>=0;j++) System.out.print (word.charAt(j)); System.out.print (" "); } } } }