How to take only integer input through keyboard in java


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: How to take only integer input through keyboard in java

Hybrid View

  1. #1
    Jane Guest

    How to take only integer input through keyboard in java


    hello,
    I know to take characters as input from keyboard in java. Can anybody
    please let me know how to input integers from keyboard. For every input do
    we have to create seperate objects of BufferedReader? Can we manipulate the
    data also?
    Thanks,
    Jane.

  2. #2
    Tim Guest

    Re: How to take only integer input through keyboard in java


    Dear Jane,

    It was nice to know ur question. I am ready to answer it to u only if u do
    me a personel favor (u know what I mean).

    Thanx,

    Tim

    "Jane" <jane_rocks2001@yahoo.com> wrote:
    >
    >hello,
    > I know to take characters as input from keyboard in java. Can anybody
    >please let me know how to input integers from keyboard. For every input

    do
    >we have to create seperate objects of BufferedReader? Can we manipulate

    the
    >data also?
    >Thanks,
    >Jane.



  3. #3
    Walker Guest

    Re: How to take only integer input through keyboard in java


    "Jane" <jane_rocks2001@yahoo.com> wrote:
    >
    >hello,
    > I know to take characters as input from keyboard in java. Can anybody
    >please let me know how to input integers from keyboard. For every input

    do
    >we have to create seperate objects of BufferedReader? Can we manipulate

    the
    >data also?
    >Thanks,
    >Jane.



  4. #4
    Walker Guest

    Re: How to take only integer input through keyboard in java


    "Jane" <jane_rocks2001@yahoo.com> wrote:
    >
    >hello,
    > I know to take characters as input from keyboard in java. Can anybody
    >please let me know how to input integers from keyboard. For every input

    do
    >we have to create seperate objects of BufferedReader? Can we manipulate

    the
    >data also?
    >Thanks,
    >Jane.


    here is something that might help - just a code snipit;

    // import the package you need
    import javax.swing.JOptionPane;

    // set up some variables
    String keyBoardStuff;
    int myInt=0;

    // now get the integer
    keyBoardStuff = JOptionPane.showInputDialog(
    "Enter the integer: ");

    // now convert from the string data to integer
    myInt = Integer.parseInt(keyBoardStuff);

    //now your integer data is in the variable myInt

    Hope this helps;
    Walker


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center