title: Checking if a string contains only digits ? (isDigitMethod required)
body: <p>The user should give a string, where we should check if all characters are numbers.
  If <em>all</em> are digits, we will get one message that the password is with digits and move on with the program. If any of them (or all) is not a digit, then the user should enter password again. 
  (E.g. <code>465486</code> is acceptable. <code>hell3429384</code> or <code>sfdkjsfkj</code> is not acceptable) </p>
  
  <p>Apparently, my code is not working correctly, since whether I give a number or a letter to the password, I get the same result.
  Am I looping something wrong, or am I using the <code>isDigit</code> method wrong? </p>
  
  <pre><code>import java.util.*; 
  public class Password {
      public static void main(String[] args) {
          Scanner passn = new Scanner(System.in);
          System.out.println("Give password: "); 
          String pass = passn.nextLine(); /* user enters password*/
          int length = pass.length();
          boolean isadigit; 
          for(int i = 0; i &lt; length; i++) { /*looping each character one by    one*/     
              char character= pass.charAt(i);
              if (Character.isDigit(i)) { /*checking if each character is digit*/
                  isadigit = true; /* if it is, give the value to isadigit true*/
                  System.out.println("PASSWORD is w digits");
              }
              else {
                  System.out.println("PASSWORD w/out digits");
                  passn.nextLine();
              }
          }
      }
  }
  </code></pre>