[Solved] Is there a simpler way of to write this java program?


You can do it using indexOf and substrings:

int index= word.indexOf(" ");
do{
  System.out.println(word.substring(0, index));
  word = word.substring(index + 1);
  index = word.indexOf(" ");
} while (index != -1);

solved Is there a simpler way of to write this java program?