Java User Data entry

Source: Internet
Author: User

Data entry

First you need to import a scanner

Then declare the scanner

Output input Prompt

Receive data from user data

Output data for user data

Instance:

ImportJava.util.Scanner;//Import Scanner Public classtest{ Public Static voidMain (string[] args) {Scanner in=NewScanner (system.in);//declare scanner, assign scanner to inSystem.out.println ("Please enter your name:");//Output input PromptString name = In.next ();//receive user-entered names        /*when the user input is received, In.next () is the Receive string type In.nextint () is the receive integer in.nextdouble () is the receive double type*/System.out.println ("Please enter your age");//Output input Prompt        intAge = In.nextint ();//age to accept user inputSystem.out.println ("Please enter your gender");//Output input PromptString sex = In.next ();//Accept user-entered gender//output All information entered by the userSystem.out.println ("name" +name); System.out.println ("Age" +Age ); System.out.println ("Gender" +sex); }}

Java User Data entry

Related Article

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.