Check out example codes for "Don't use a line-beased input after a token-based input.". It will help you in understanding the concepts better.

Code Example 1

import java.util.Scanner;

public class Test {
  public static void main(String[] args) {       
    Scanner input = new Scanner(System.in);
    System.out.print("Enter an integer: ");
    int value = input.nextInt();
    System.out.println("The value is " + value);

    System.out.print("Enter a line: ");
    String line = input.nextLine();
    System.out.println("The line is " + line);
  }
}

Code Example 2

Enter a phone word: warbler
The number is 9272537.

Enter a phone word: GOOD4U2
The number is 4663482.

Enter a phone word: OMG
Your phone word is not long enough for a phone number.

Enter a phone word: GREAT DEALS
The number is 4732833.

Learn ReactJs, React Native from akashmittal.com