public static int parseInt(String num) {
int index = 0;
int result = 0;
if (num.startsWith("-")) {
index++;
}
while (index <= num.length() - 1) {
int n = num.charAt(index);
if (n <= 57 && n >= 48) {
result *= 10;
result += n - 48;
} else {
System.err.println("args is not a interger");
}
index++;
}
if (num.startsWith("-")) {
result = -result;
}
return result;
}
int index = 0;
int result = 0;
if (num.startsWith("-")) {
index++;
}
while (index <= num.length() - 1) {
int n = num.charAt(index);
if (n <= 57 && n >= 48) {
result *= 10;
result += n - 48;
} else {
System.err.println("args is not a interger");
}
index++;
}
if (num.startsWith("-")) {
result = -result;
}
return result;
}