As you can see in this code an integer input is gathered and then in a for loop strings are gathered in an array. I have used the hasNextLine while loop method in the string for loop but it stays in an infinite loop. The error is found at line 47.
public static void main(String[] args) {
LabClass scall = new LabClass();
Scanner scnr = new Scanner(System.in);
// assignments
int listSize = 0;
System.out.println("Enter list Amount");
listSize = scnr.nextInt();
// removing line to allow input of integer
int size = listSize; // array length
// end of assignments
String [] wordsList = new String[size]; // string array
for (int i = 0; i < wordsList.length; i++) { //gathers string input
wordsList[i] = scnr.nextLine();
}
for (int i = 0; i < listSize; i++)
{
String currWord = wordsList[i];
int freqCount = getFrequencyOfWord(wordsList,listSize,currWord);
System.out.println(currWord + " " + freqCount);
}
}
}