is All Char Digit in a string - Android java.lang

Android examples for java.lang:Character

Description

is All Char Digit in a string

Demo Code

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main{

    public static boolean isAllCharDigit(String str) {
        int length = str.length();
        if (length == 0) {
            return false;
        }/* w  w  w  .j a va 2 s. c  o  m*/
        for (int i = 0; i < length; i++) {
            if (!Character.isDigit(str.charAt(i))) {
                return false;
            }
        }
        return true;
    }

}

Related Tutorials