Tuesday, November 2, 2010

How to use isDigit function in java?

I have sample used method isDigit in java...

package com.andia.cm;

public class IsDigit {
    public static void main(String[] args) {

        String file = "Test123Test";
        char result = ' ';

        for (int i = 0; i < file.length(); i++) {

            if (Character.isDigit(file.charAt(i))) {
                result = file.charAt(i);
            }
        }
        System.out.println(result);
    }
}

No comments: