View Full Version : cin >> in java?
chipdouglas
03-16-2003, 12:20 AM
that's my question. i hope this posts, cause it wouldn't the first 2 times i tried
I guess your question is "what is the java equivalent of c++'s cin".
There is no direct thing.You need to import java.io and see the classes in them and look for the one which is suitable for your purpose(example: DataInputStream Class)
Go through the java documentation for the classes in the package "java.io"
Spookster
03-17-2003, 08:40 PM
As psp mentioned you will need to import the java.io
and then something like this will work just fine:
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
then you can use method like readLine() to read in the input:
int input;
input = Integer.parseInt(br.readLine());
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.