I wrote a program that loops through a string array and prints the unique words and their occurrences, and then prints them to a file. This part works perfectly, but I'm having trouble figuring out how to get the total count of unique words. I have a feeling I need to create an int array for a counter, but I'm not exactly grasping how to do this. Unfortunately I am NOT allowed to use Hashmap, Sets, or Lists; have to stick with Arrays.
boolean [] done = new boolean[textfile.length];
for(int i = 0; i<textfile.length; i++){
if(done[i])
continue;
int nb = 0;
for(int j = i; j < textfile.length; j++){
if(done[j])
continue;
if(textfile[i].equals(textfile[j])){
done[j] = true;
nb++;
}
}
pw.println(textfile[i] + "occurs " + nb + " times");
}
nb??