I am very new to Java but am working through the book Java: How to program (9th ed.) and have reached an example where for the life of me I cannot figure out what the proble
Integer#nextInt throws NoSuchElementException - if input is exhausted
Integer#nextInt
NoSuchElementException
You should check if there is a next line with Integer#hasNextLine
Integer#hasNextLine
if(sc.hasNextLine()){ number1=sc.nextInt(); }