We would like to know how to use Scanner to receive user input.
// ww w . jav a 2 s . com import java.util.Scanner; public class MainClass{ public static void main(String[] args){ Scanner scanner = new Scanner (System.in); String s = scanner.next (); System.out.println(s); } }
The code above generates the following result.