Java Basic Knowledge Hardening 29:scanner Class Scanner overview

Source: Internet
Author: User

1.Scanner Overview:

JDK5 later used to get the user's keyboard input

2.Scanner Method of Construction:

Public Scanner (InputStream source)

3. Case:

1  Packagecn.itcast_01;2 3 /*4 * Scanner: Used to receive keyboard input data. 5  * 6 * In front of the time:7 * A: Guide Package8 * B: Create object9 * C: Call methodTen  *  One * There is a static field under the System class: A * public static final inputstream in; standard input stream, corresponding to keyboard input.  -  *  - * InputStream is = system.in; the  *  - * Class Demo { - * public static final int x = ten; - * public static final Student s = new Student (); +  * } - * int y = demo.x; + * Student s = demo.s; A  *  at  *  - * Construction Method: - * Scanner (inputstream source) -  */ - ImportJava.util.Scanner; -  in  Public classScannerdemo { -      Public Static voidMain (string[] args) { to         //Creating Objects +Scanner sc =NewScanner (system.in); -  the         intx =sc.nextint (); *          $System.out.println ("x:" +x);Panax Notoginseng     } -}

Java Basic Knowledge Hardening 29:scanner Class Scanner overview

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.