S
soup_or_power
The following code works as expected and breaks when a non-digit is
found in the string test
//string test set somewhere in the code
for(int i=0; i < test.length(); i++) {
if (Character.isDigit(test.charAt(i)) )
continue;
flg=1;
break;
}
The following code does not work.
for(int i=0; i < test.length(); i++) {
if (!Character.isDigit(test.charAt(i)) ) {
flg=1;
break;
}
}
I tried printing Character.getType(test.charAt(i)) and it is always 9
indicating decimal digit. Can someone please clarify what's being done
wrong?
Thanks
found in the string test
//string test set somewhere in the code
for(int i=0; i < test.length(); i++) {
if (Character.isDigit(test.charAt(i)) )
continue;
flg=1;
break;
}
The following code does not work.
for(int i=0; i < test.length(); i++) {
if (!Character.isDigit(test.charAt(i)) ) {
flg=1;
break;
}
}
I tried printing Character.getType(test.charAt(i)) and it is always 9
indicating decimal digit. Can someone please clarify what's being done
wrong?
Thanks