title: java validate String containing numbers and search to make sure there are no characters
body: <p>I want to validate a user input phone number, the first thing I need to do is check to make sure that the length of the input string is 10 which isn't an issue as you'll see in my code.</p>
  
  <p>Now is where the problem comes in, I also need to check to make sure no characters have been entered in as well, any ideas on how to do this with out the use of Arrays. I'd like to use Character.isLetter(); but no matter how I implement it it's not coming out right.</p>
  
  <pre><code>import java.util.Scanner;
  public class Example 
  {
     public static void main(String[] args)
     {
        boolean isNumber = false; 
        String phoneNum = "";
        Scanner input = new Scanner(System.in);
  
          while(!isNumber)
          {
             System.out.print("\nEnter your 10 digit phone number (ex: 2123345657): ");         
             phoneNum = input.nextLine(); 
  
               /* Yes I could use nextInt(); etc.. but that would defeat the 
                purpose of this exercise */
  
                if(phoneNum.length() != 10)
                {
                  System.out.println("\n\nBad input");
                }
                else 
                    isNumber = true;
          }
  
          System.out.println("\n\nPhone number is: " + phoneNum);
  
  
     }
  
  }
  </code></pre>
  
  <p>I was looking for some thing like this. </p>
  
  <pre><code>while(!isRight)
      {
              System.out.print("\n input number: "); 
              phoneNum = input.nextLine();  
  
              while(i &lt; phoneNum.length())
              {   
                  if(phoneNum.length() != 10)
                  {
                      System.out.println("not enough numbers");
                  } 
  
  
                  else if (Character.isLetter(phoneNum.charAt(i)) == true)
                  {   
  
                      System.out.println("Sorry you can't use any thing but numbers");
                  }
  
                  else 
                      isRight = true;
                  i++;
              }
      }
  </code></pre>