How do I....


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: How do I....

  1. #1
    Join Date
    Nov 2002
    Posts
    4

    How do I....

    I use showInputDialog OptioPane.

    I want the user to enter a number.....How do I check the value of what the user enterd......If the user enterd a letter....or a word ....How do I check his input?
    Tal

  2. #2
    Join Date
    Nov 2002
    Posts
    138
    use a try-catch block using a numberformatexception. i am not sure with this exception's name but look it up. this should do. so anytime the user enters a non-number character, the error is caught and the user will have to do it again.

  3. #3
    Join Date
    Dec 2002
    Posts
    17
    use try-catch blocks, or you can use "ifs" since they are more efficient.

    for example, if you DO NOT have to worry about handling the input which allows a string or numeric:

    if(input>=0)
    { do this }
    else
    {System.out.println("please enter a number");}

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