How to get input

Source: Internet
Author: User

Public class Iotestnext {

Public Static void Main (string[] args) {

/*

* 1. The first way: use of Java.util.Scanner

*

Scanner sc=new Scanner (system.in);

System.out.println ("Waiting Inputchar:");

String N=sc.next ();

SYSTEM.OUT.PRINTLN (n);

*/

/*

* 2. The second way: java.io

*

InputStream input=system.in;

You can also use BufferedReader to get input

BufferedReader input=new BufferedReader (New InputStreamReader (system.in));

Byte[] B=new byte[100];

try {

Input.read (b);

} catch (IOException e) {

E.printstacktrace ();

}

String Str=new string (b);

System.out.print (str);

*/

/*

* 3. The third Way: java.io.Console;

* Description: There is no main console in eclipse, so the following methods are not available, but can be used in Windows cmd

*/

Console Console=system.console ();

if (console==null) {

SYSTEM.OUT.PRINTLN ("Cannot use the console");

Return

}

String str= console.readline ();

System.out.print (str);

*/

}

}

How to get 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.