Its telling me I need a return statement on the last line of my method even though that part can never be executed.. I am a novice at Java and I am teaching myself.. so is it just me that has bad coding style or is the java compiler a bit too OCD?
public static String translate(String[] sourceLanguage, String[] destinationLanguage, String toBeTranslated){
int i;
//assume the word to be translated is not translatable,
boolean isTranslatable = false;
//check every word in the sourceLanguage array for that word.
for (i = 0; i < (sourceLanguage.length); i++){
//If it is there conclude that it can be translated and hence return it's equivalent
if (toBeTranslated.equals(sourceLanguage[i])){
isTranslatable = true;
return (destinationLanguage[i]);
}
}
//if it still is not translatable, return "?????" to show confusion.
if (isTranslatable == false){
return ("?????");
}
return "This is dead code anyway";//the javac insisted on this..
}