Results 1 to 4 of 4
  1. #1
    radhi16 is offline Member
    Join Date
    Jan 2011
    Posts
    30
    Rep Power
    0

    Default How to test whether the entered value is numeric or it contains some characters.

    here is the code which i have written
    Java Code:
    
    import java.util.Scanner;
    
    public class Assignment {
    
        public static void main(String[] args) {
            int row, column;
             
            int s=0;
            boolean found = false;
            String rollNumber;
            
            while (!found) {
    
                try {
                    Scanner scan = new Scanner(System.in);
                    System.out.print("Enter the size of the array s: ");
                   String size = scan.next();
                    
                    System.out.println("size is :" +size);
                  System.out.println();
                      
                   found = true;
                    
                } catch (NumberFormatException nfe) {
                    System.out.print("Please enter the number again in correct format:");
                    System.out.println();
    
    
                }
    
            }
            
           // int[][] arr = new int[size][3];
            
    
        }
    }

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,839
    Rep Power
    8

    Default

    What's your question? Where are you stuck? What have you tried?

    See the APIs for String and Character for useful functions.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    radhi16 is offline Member
    Join Date
    Jan 2011
    Posts
    30
    Rep Power
    0

    Default

    got the answer.

  4. #4
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    So post it (along with clarification of the question) so if someone else with the same problem can also get help.

Similar Threads

  1. Replies: 4
    Last Post: 11-05-2010, 10:43 AM
  2. Replies: 13
    Last Post: 09-23-2010, 07:21 PM
  3. JXL, Numeric data issue
    By only2008 in forum Java Servlet
    Replies: 0
    Last Post: 02-27-2009, 11:36 AM
  4. get numeric value from a text field
    By Lehane_9 in forum New To Java
    Replies: 2
    Last Post: 06-14-2008, 03:19 AM
  5. Allowing only numeric values in a TextField
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 03-01-2008, 10:08 PM

Posting Permissions

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