Here is a Java program that helps you to understand how to use the Scanner class to capture user input. The Scanner class is used to get user input, and it is found in java.util package.
Using Scanner class in Java program (code of the program)
public class ScannerTest //public main class, to be saved in a file with .java
public static void main(String args)
Scanner keyboard=new Scanner(System.in);
System.out.println(“###Enter the number of teams followed by”);
System.out.println(“the number of players per team###” );
System.out.println(“Tournament is participated by “+ tot_num_players +” players.”);