Okay,
>>16-chan, so here are the ways in which
your anus enjoys extracting every last drop of my cum with a delicate squeeze of its folds. First, you're checking whether
isTranslatable has been set to
false, even though it will always be false once that loop exits. This introduces your actual problem: The Javac is smart enouch to notice that you neglected to handle the
else condition of your
if statement, but
not smart enough to notice that the
if statement is itself completely redundant.
Second, you're combining two forms of program logic anyway!
>>18-kun wrote a nice version that does what you want, but here's a version that separates the logic in a way you might understand bettar.
public static String translate(String[] sourceLanguage, String[] destinationLanguage, String toBeTranslated) {
int i = lookup(toBeTranslated, sourceLanguage);
if (i < 0) { // ...then the string is not in sourceLanguage.
return "?????";
} else {
return destinationLanguage[i];
}
}
public static int lookup(String whatever, String[] inAnArray) {
for (int i = 0; i < inAnArray.length; i++) {
if (w.equals(whatever)) {
return i;
} else {
// do nothing, let the loop continue
}
}
// Wasn't found
return -1;
}