Remove the semi-colon after the while. Because of the semi-colon, the block after the while
is an independent block as the while
loop terminates at the ;
with an empty statement. The while condition always stays true
and thus the infinite loop.
while(s1.hasNextInt())