mercredi 16 novembre 2016

Why doesn't this work? [Variables and the if-statement] [Java] [duplicate]

This question already has an answer here:

I am a beginner in java, I was making a simple java program that decides wether you get a "Mr." or a "Mrs." depending on your sex, but whenever I rurn the program I get this:

"Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous sym type: system.out.println at learningjava.LearningJava.main"

this is my code:

public class LearningJava {

public static void main(String[] args) {
    String sex;
    String honorific;
    sex = "Male";
    if (sex == "Male") {
        honorific = "Mr.";
} else if (sex == "Female") {
        honorific = "Mrs.";
}
    system.out.println(honorific);
}}

Thanks!

Aucun commentaire:

Enregistrer un commentaire