User input -Scanner scanner

Scanner Scanner

1. create a scanner - >> remember the lead pack alt + enter

Scanner sc=new Scanner(system.in);

 

retrieve data

1.sc.nextInt (); // enter an integer

2.sc.nextDouble (); // input decimal

3.sc.nextLine (); // input string

 

Example:

 

Result: the input string is not because no input.

Guess you like

Origin www.cnblogs.com/gxtoo/p/12194611.html