2 回答
TA贡献1841条经验 获得超3个赞
public class MyTest {
public static int fn(Integer a){
return a.toString().length() > 1 ? Integer.parseInt(a.toString().substring(1)) : 0;
}
public static void main(String[] args) {
System.out.println(fn(5));
System.out.println(fn(10));
System.out.println(fn(10001));
System.out.println(fn(12345));
System.out.println(fn(50123));
}
}

TA贡献1886条经验 获得超2个赞
a = 10001;
a.toString().substring(1,) * 1;
//或者
parseInt(a.toString().substring(1,));
好吧,问题改成java了,下面貌似不太优雅
int a = 10001;
String s = String.valueOf(a);
System.out.println(Integer.parseInt(s.substring(1, s.length())));
添加回答
举报
