Case insensitive and if statements
My Code: ---------------------------------------------------------------------------------------------------- import java.util.Scanner; public class Codes { public static void main(String[] args) { Scanner read = new Scanner(System.in); System.out.println("Please enter your name: "); String name = read.nextLine(); System.out.println("Please specify your gender(M/F): "); String gender = read.nextLine(); if(gender == "m") { System.out.println("Welcome Mr." + name); } else if(gender == "f") { System.out.println("Welcome Ms." + name); } else { System.out.println("Invalid input. Please re-open the program to re-enter your information"); } } } ---------------------------------------------------------------------------------------------------- My question is how do I make it case insensitive and even though I enter the gender with lower-case, it only shows the "else" statement, why it doesn't work?