Welcome to the Ranch
Please tell us the
full details. What goes wrong? Does the program compile? Does it throw Exceptions?
What is
ks? Why is it there at all? You should always start off a for loop like this:-
for (int i = 0; i < myArray.length; i++) ...
Now there is no need for ks. You may need to change that loop later, but you should always think of that as the basic form of the for loop. I think you would do better to use a for‑each loop, however.
If you find 4 spaces, how many words do you have?
Have you come across
a String method to create a String[]? Try it with "\\s+" as its argument. That is a regular expression for any number (> 0) of whitespace characters.
Don't use _ in variable names. Use mixedCaseWriting. Using _ except for constants is incorrect Java® style.