I used this code:
Scanner SC = new Scanner(System.in);
String Gender = " ";
System.out.println("....");
String Ans1 = SC.nextLine();
Ans1 = Ams1.toLowerCase();
if(Ans1 == "yes") {
Gender = "male";
System.out.println(Gender);
}
else {
System.out.println("Get out!");
}
I think I used the Gender
variable in if statement
, but it's showing The Value of the local Variable is not used
.
And when I ran, it works but the value of gender is the same as the previous. It means that if I write yes
it doesn't show the word male
it shows the space I gave.
Please Help!