Java 去掉数字字符串开头的 0 三种方法(推荐)
int result = Integer.parseInt(tempStr);
result 结果: 123
- String newStr = str.replaceFirst("^0*","");
- System.out.println(newStr);
打印结果: 123
- String newStr = str.replaceAll("^(0+)","");
- System.out.println(newStr);
打印结果: 123
来源: http://www.bubuko.com/infodetail-3202714.html