DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
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");}

Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links