if the store the words below "if(sentence.charAt(i) == ' ')" the output comes "T. . . ."
try with other delimiters, such as
_ and you can see that each
word begins with this delimiter
To see that do the following steps:
1. Comment out line 28
//word += sentence.charAt(i);
2. Change a line 30 to
if(sentence.charAt(i) == '_')
3. Comment in line 37
//word += sentence.charAt(i);
4. Add a new line 38:
System.out.println("iteration: " + i + " word: " + word);
5. Run the program and enter a sentence suppose
This_is_a_cat
Hint: Clean your code, e.g. write line 25:
for(int i = 0; i < sentence.length(); i++) and delete lines 20 and 23, etc...