How could I detect the 'enter' and break (if number???) in the code below?
Thanks!
public static void readNumbers(Scanner reader, ArrayList<Integer> list) {
System.out.println("Give numbers, ‘enter’ will stop.");
while (true) {
int number = Integer.parseInt(reader.nextLine());
if (number ????) {
break;
}
list.add(number);
}
}
Aucun commentaire:
Enregistrer un commentaire