1. How to read and output a data or array from the console
Input a number and Output2Medium Method
1) bufferedreader BR =NewBufferedreader (NewInputstreamreader (system.In); // Read one
Number
String
STR = Br. Readline ();
IntI = integer.Parseint(STR );
System.Out. Print (I );
2)Byte[] B =New Byte[10]; // another way to read one number
System.In. Read (B );
String
S =NewString (B );
IntJ = integer.Parseint(S. Trim ());
System.Out. Println (s );
System.Out. Println (j );
Input an array and output it:
Bufferedreader Br2 =NewBufferedreader (New
Inputstreamreader (system.In));
IntA [] =New Int[10]; // a way to read array and print
For(IntK = 0; k <A. length; k ++ ){
A [k] = integer.Parseint(Br2.readline ());
}
For(IntK = 0; k <A. length; k ++ ){
System.Out. Println (A [k]);
}
In this process, you must note that these codes must capture exceptions!