-
Hello ...
Okay I am trying to do a simple function.
That is just getting the users imput from what they type and store it into a variable.
I dont know how to do this in Java but this is what I want.
Code:
printf("Enter in your age: ");
scanf("%d",&age);
}
How to do this in java?
Code:
int age=0;
System.out.println("Enter in your age: ");
Sytem.in???????????
Thanks for the help :)
-
class Sysintest{
public static void main(String[] args){
BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter your name");
String name = (stdIn.readLine());
// read line returns a string
}
}
Any Questions ????
-
The BufferedReader class applies buffering to a
character input stream thereby improving the
efficiency of character input. BufferedReader also
provides a replacement for the depreacated readLine()
method of DataInputStream, which did not properly
convert bytes to characters.