Question from the Java test

Check if two strings are equal in Java

Easy

what is the output of the follwing code?

public static void main(String[] args) {
         String s1 = "java";
         String s2 = "geek";                                                                                                                                                                        
         String s3="Javageek";            
         System.out.println(s3==s1+s2);
    }
Author: FodiéStatus: Published(Update)Question passed 128 times
Edit
1
Community Evaluations
developer avatar
Auteur anonyme
23/05/2023
Any explication of this ?
developer avatar
Fodié
24/05/2023
In the given code, s1 + s2 will create a new string "javageek". However, the reference of this new string is not the same as the reference of s3, even if their values are equal.