private void playCode(String code) {
String tmp;
while(code != "") {
If(code.indexOf("f") == 2) { //Read Code
tmp = code.substring(0, 3);
code = code.substring(3);
} } else {
tmp = code.substring(0, 2);
code = code.substring(2);
}
}
}
To explain, there is a string called code (for example, C4D4D4D4f is configured in this way)
Until the code in the while statement leaves no text, Cut two or three characters each and store them in a variable called tmp I'm trying to erase as many parts of the existing code variable as the part stored in tmp through substring.
However, if you compile after coding as above, there will be an error when running the Android app If you erase the code inside the while statement, the execution will be normal... What's wrong with this?
android java eclipse
I repeatedly substring the code value.
If the code length at the time of the error is less than 2 or 3, the error will occur.
© 2024 OneMinuteCode. All rights reserved.