I get the following error in my java code:
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 6
...which occurs at the following line:
if (strFactor.charAt(j) == strProduct.charAt(k)) {
Here is the code:
for (int j=0; 0<=5; j++) {
same = false;
for (int k=0; k<=5; k++) {
if (strFactor.length() == 6 && strProduct.length() == 6) {
if (strFactor.charAt(j) == strProduct.charAt(k)) {
same = true;
}
}
}
if (!same) {
return false;
}
}
Anyone have any idea why the index would ever be out of range?