Assuming the string is not null, and contains nothing but numeric numbers
public boolean test(String s) {
if(s.length()<2) return true;
char t = s.charAt(0);
for(int i = 1; i<s.length(); ++i) {
if(t!=s.charAt(i)) return false;
}
return true;
}
I would not say it's "the best", but it will do...