is String Numeric String - Android java.lang

Android examples for java.lang:String Parse

Description

is String Numeric String

Demo Code


//package com.java2s;

public class Main {
    public static boolean isNumericString(String s) {
        boolean b = true;
        for (int i = 0; i < s.length(); i++) {
            if (!isNumeric(s.charAt(i))) {
                b = false;/*from   w  w w .  j  a v a  2  s . c o  m*/
                break;
            }
        }
        return b;
    }

    public static boolean isNumeric(char c) {
        return (c >= '0' && c <= '9');
    }
}

Related Tutorials