The block of code I refer to in my header is:
for (String itemOfMyNumbers : arrayOfInputLine) {
for (int itemOfLatestNumbersArray = 2; itemOfLatestNumbersArray < 7; itemOfLatestNumbersArray++) {
if (latestNumbersArray[itemOfLatestNumbersArray] == itemOfMyNumbers) {
found = 1;
}
}
}
This block compares 2 strings both found in String[] types and if they match it sets found = 1 Pretty simple stuff.
If I compile this by hand on a command line (Linux style) it works as I'd expect, but if I use it in a method of a class in an Android Studio project found is never set. The "Strings" I am feeding the for loops just happen to be integers anyway so I can do :
for (String itemOfMyNumbers : arrayOfInputLine) {
for (int itemOfLatestNumbersArray = 2; itemOfLatestNumbersArray < 7; itemOfLatestNumbersArray++) {
if (Integer.parseInt(latestNumbersArray[itemOfLatestNumbersArray]) == Integer.parseInt(itemOfMyNumbers)) {
found = 1;
}
}
}
That makes it now work.
Why can I compare String types with a simple == on the command line but not within an Android Studio project?
0 comments:
Post a Comment