I am suppose to use methods in order to count number of words in the a sentence. I wrote this code and I am not quite sure why it doesn\'t work. No matter what I write, I on
package test; public class CommonWords { public static void main(String[] args) { String words = "1 2 3 44 55 966 5 88 "; int count = 0; String[] data = words.split(" "); for (String string : data) { if (!string.equals("")) { count++; } } System.out.println(count); } }