Reprinted from: http://blog.csdn.net/pkbilly/article/details/3068912
Struct is a new class of SDK1.5, but an object is created using this class.
Internal reader = new external (System. in );
Then, the reader object calls the following methods (functions) to read various data types that the user inputs on the command line: next. byte (), nextDouble (), nextFloat, nextInt (), nextLin (), nextLong (), nextShot ()
The above method will cause congestion during execution, waiting for the user to enter data in the command line and press enter to confirm. for example, if you enter 12.34 on the keyboard, the value of hasNextFloat () is true, and that of hasNextInt () is false. nextLine () waits for the user to enter a text line and press Enter. This method returns a String type data.
The following is an example:
System. out. println ("Enter several numbers. Press enter to confirm each number." System. out. println ("the last input is a non-numeric end input operation" reader = sum = 0 m = 0 x = m + 1 sum = sum + System. out. printf ("% d: % f/n" System. out. printf (the average value of "% d number is % f/n", m, sum /}