What does return -1 in Java mean?
public convertStringToInt(String num){
int result = 0;
int zeroAscii = 48;
int nineAscii = 57;
for (char c: num.toCharArray()){
if(c>=zeroAscii && c<=nineAscii){
result = result*10 + (c-nineAscii);
}
else{
return -1;
}
}
return result;
}
参考:https://stackoverflow.com/questions/24735741/return-1-in-java#