Java Scanner’s unexpected behavior following nextInt or nextDouble call
Scanner is a utility class that provides methods to read command-line input. It is a very useful class, but you need to be aware of its unexpected behavior while reading numeric inputs. Consider the following example.