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

[ad_1]

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);

[ad_2]

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