Java lifecycle usage

Source: Internet
Author: User

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 /}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.