I have a while loop that's supposed to end when there are no more integers to be read. For some reason, it continues to keep checking (or at least I believe so) and won't return the print statement. My sample input would look like,
20 21 22 23
I've tried hasNextLine()
before hasNextInt()
, try/finally blocks and closing the scanner as well as reading through the forums.
If I phrased/formatted the question wrong or if there's another resource I haven't come across yet I would appreciate some feedback. I'm really just trying to learn.
public static void main(String[] args) {
x = 0;
in = new Scanner(System.in);
while (in.hasNextInt()) {
x = in.nextInt();
reverse(x);
beautiful(x, reverse(x), y);
}
printCount(count);
}