The 4th Chapter Java receives user input

Source: Internet
Author: User
The 4th Chapter Java receives user input 1. Input

Use the Scanner tool class to exchange data entered by the user
The scanner class is located in the Java.util package and needs to be imported when using the package
Steps to use:

1. Import the Java.util.Scanner class
例:import java.util.Scanner
2. Create a Scanner object
例:Scanner input=new Scanner(System.in);
3. Receive and save user input values
例:int score=input.nextInt();input之后可以选择很多方法,注意使用一般是先提示后输入
A few common differences between print and println and printf.

Print no newline output
println line break output
printf with%s (formatted) output

Generated by Haroopad

The 4th Chapter Java receives user input

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.