Here you can find the source of isDigits(String s)
public static final boolean isDigits(String s)
//package com.java2s; public class Main { public static final boolean isDigits(String s) { if (s == null || s.length() == 0) return false; int begin = (s.charAt(0) == '-') ? 1 : 0; for (int i = begin; i < s.length(); i++) { if (!Character.isDigit(s.charAt(i))) return false; }/*from ww w. ja v a 2s .c om*/ return true; } public static final boolean isDigits(Object o) { if (o == null) { return false; } String s = o.toString(); if (s.length() == 0) return false; //?????? int i = (s.charAt(0) == '-') ? 1 : 0; for (int j = s.length(); i < j; i++) { if (!Character.isDigit(s.charAt(i))) return false; } return true; } }