PDA

Click to See Complete Forum and Search --> : Java help


Help
Feb 5th, 2001, 11:36 PM
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.


printf("Enter in your age: ");
scanf("%d",&age);
}



How to do this in java?

int age=0;
System.out.println("Enter in your age: ");
Sytem.in???????????

Thanks for the help :)

Dillinger4
Feb 6th, 2001, 07:13 PM
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 ????

Dillinger4
Feb 6th, 2001, 07:26 PM
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.