[Java] Why do these strings return false?
I have this code in Java. The first comparison returns false (both are strings), the returns true (again, both strings). Why? public class Main { public static void main(String[] args) throws Exception { String s1 = new String("wow"); String s2 = "wow"; System.out.println(s1.getClass().getSimpleName()); //returns "String" System.out.println(s2.getClass().getSimpleName()); //returns "String" System.out.println(s1 == s2); //returns "false" String s3 = "wow"; String s4 = "wow"; System.out.println(s1.getClass().getSimpleName()); //returns "String" System.out.println(s2.getClass().getSimpleName()); //returns "String" System.out.println(s3 == s4); //returns "true" } } https://code.sololearn.com/ciypzm8n8bI2/?ref=app