I've got the following java problem: I need to find out which word has the biggest occurrence in a String. Example String:
String text = "Holy Diver is [...] band.";
what I've already done is:
String array[] = text.split("\\s");
Arrays.sort(array);
for (int i = 0; i < array.length; i++) {
System.out.println(array[i]);
}
What I thought about:
for (int d = 0; d < array.length; d ++) {
System.out.println(d);
if (array[d].equals(array[++d])) {
d--;
System.out.println(d);
counter++;
int[] e = new int[d];
} else {
counter = 0;
}
}
Doesn't work for obvious reasons. I don't know if I am on the right way.