Check String is Numeric in Java

public static  boolean isNumeric(String nums){
        List<Integer> numbers = Arrays.asList(new Integer[]{46,48,49,50,51,52,53,54,55,56,57});
        int numCnt=0;
        char[] c = nums.toCharArray();
        for (int d : c) {
            if(numbers.contains(d)){
                numCnt++;                
            }
        }
        return numCnt == c.length;
    }
Advertisements
This entry was posted in Core JAVA, Scripting in JAVA. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s