Hi Sang,
I am just at the elementary level in the Java tutorials( first course), I
have some question or a little more insight into the logic. In the sample
code for bufferedReader shown below:
1 import java.io.BufferedReader;
2 import java.io.InputStreamReader;
3 import java.io.IOException;
45
public class GetInputFromKeyboard {
67
public static void main( String[] args ){
8 BufferedReader dataIn = new BufferedReader(
9 new InputStreamReader( System.in) );
10
11 String name = "";
12 System.out.print("Please Enter Your Name:");
13 try{
14 name = dataIn.readLine();
15 }catch( IOException e ){
16 System.out.println("Error!");
17 }
18 System.out.println("Hello " + name +"!");
19 }
20 }
we created a new variable to hold the new instance of BufferedReader class
:" dataIn"
I am not sure I understand why we need to create a new string variable
again : "name" and then equate "name" to "dataIn"
My second question is, I think the readLine() method does the same thing as
code number 8 and 9, if not whats the difference.
regards
--
You received this message because you are subscribed to the Google Groups
"JPassion.com: Java Programming" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
Visit this group at http://groups.google.com/group/jpassion_java.
For more options, visit https://groups.google.com/d/optout.