My code below takes in all the words from a txt file and beside it prints out the number 1(count). The aim of my program is to take in all the words like its doing but if it is a duplicate i don't want it to print the word I want it to find its match and add one to its count.
Scanner in = new Scanner(new File(filename));
int i = 0;
int n = 1;
String w = "";
String txt = "";
while ((in.hasNext())) {
w = in.next() ;
wrd[i] = w;
num[i] = n;
i++;
txt = wrd[i];
}
Scannerfor reading from aFile. What wrong hasFileReaderdone to you?