Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: cin >> in java?

  1. #1
    New to the CF scene
    Join Date
    Mar 2003
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    cin >> in java?

    that's my question. i hope this posts, cause it wouldn't the first 2 times i tried

  • #2
    psp
    psp is offline
    New Coder
    Join Date
    Mar 2003
    Location
    CA
    Posts
    18
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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"

  • #3
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,273
    Thanks
    4
    Thanked 83 Times in 82 Posts
    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());
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •