void judgeLength() {
int num =111;
String s = num+"";
char fir = s.charAt(0);
if (fir == '-') {
System.out.println(s.length()-1);
} else {
System.out.println(s.length());
}
}
charAt()
方法用于返回 指定索引处的字符。索引范围为从 0 到 length() - 1。
public char charAt(int index);