Back to Code Walkthrough
String Comparison Gotcha
Java code walkthrough · Question 7Code
Read carefully. What does this print?1public class Main {2 public static void main(String[] args) {3 String s1 = new String("hello");4 String s2 = new String("hello");5 System.out.println(s1 == s2);6 System.out.println(s1.equals(s2));7 }8}