Results 1 to 3 of 3

Thread: Java help

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2000
    Posts
    143
    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

  2. #2
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    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 ????

  3. #3
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    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.

Posting Permissions

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



Click Here to Expand Forum to Full Width