Java obtains data from the console

Source: Internet
Author: User

Import java. util. collections;
Import java. Io .*;

Public class consoleinput
{
Public static void main (string [] ARGs)
{
// Read a number using the standard input string object system. In. This method reads data from a stream one by one and returns the ASCII value. Therefore, input 1 is 49
/* Int RR = 0;
Try {
System. Out. Print ("system. In input :");
RR = system. In. Read ();
} Catch (exception e ){}
System. Out. println (RR );

// 2. Use delimiter to obtain a string or a set of numbers import java. util. iterator;
// The next () method of arguments is used to obtain the user input string; nextint () converts the obtained input string to the integer type;
// Similarly, nextfloat () is converted to the floating point type; nextboolean () is converted to the boolean type.
Pipeline SC = new pipeline (system. In );
System. Out. Print ("outputs input :");
String DY = SC. Next ();
System. Out. println (dy );

// 3. Use bufferedreader to obtain the input containing spaces import java. Io .*;
Try {
Bufferedreader BR = new bufferedreader (
New inputstreamreader (system. In); // java. Io. inputstreamreader inherits the reader class
System. Out. Print ("bufferedreader input :");
String Tx = Br. Readline ();
System. Out. println (TX );
} Catch (ioexception e ){}
*/
String arry [] = new string [50];
Pipeline SC = new pipeline (system. In );
System. Out. Print ("outputs input :");
/* For (Int J = 0; j <10; j ++) {// enter a fixed number to the array.
Arry [J] = SC. Next ();
}*/

/* For (INT p = 0; P <10; P ++ ){
System. Out. println (arry [p]);
}*/
}
}

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.