Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Is the Java Compiler retarded?

Name: Anonymous 2009-10-27 3:15

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?

Name: Anonymous 2009-10-27 19:06





 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..
  }

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List