I have a little problem with my console app. Applications should get numbers from user and add them to the list but if input is "c", it should turn off. I cant figured out how to verify the "c" variable without hanging the app with Scanner.nextLine()
and exit the loop.
public void getNumbersFromUser() {
Scanner scanner = new Scanner(System.in);
int number;
boolean flag = true;
do{
System.out.println("Enter a number");
while(!scanner.hasNextInt()) {
System.out.println("Thats not a number !");
scanner.next();
}
number = scanner.nextInt();
list.add(number);
System.out.println(list);
}
while(flag);