Hello,
Are we allowed to assign different values to just one variable? For example, gender = [Female, female, fEmale] so if one a user enters any of the specified ones then he/she will be taken to the next step/level.
I'm just doing a tute at the moment and coming up with close solution to what I want to do.
public static void main (String args[]){
String gen1 = "Male";
String gen2 = new ArrayList; has errors
String gen2 =[Female, female]; has errors
String userInput;
//Taking user input now.
Scanner scan = new Scanner(System.in);
System.out.println("Please enter your gender:");
userInput = scan.nextLine();
if (userInput.equals(gen1)) {
System.out.println("Yes, true. You're a boy");
}else{
System.out.println("No, you Are not a boy. So, you must be a girl");
}
Anyone could tell the difference between .equals() function and == function and when they are used since they're very much doing the same job that is comparing two things.