给定一串数字,从中删除前导零。
public class Test {
public static void main(String[] args) {
String str = "00000123569";
System.out.println(removeZero(str)); // 123569
str = "000012356090";
System.out.println(removeZero(str)); // 12356090
}
public static String removeZero(String str) {
int len = str.length(), i = 0;
while (i < len && str.charAt(i) == '0') {
i++;
}
return str.substring(i);
}
}