Answers for "difference between equals method and == operator in java"

2

Difference between == operator and equals method in java

// == operator
String str1 = new String("Hello");
String str2 = new String("Hello");
System.out.println(str1 == str2); // output : false


// equals method
String str1 = new String("Hello");
String str2 = new String("Hello");
System.out.println(str1.equals(str2)); // output : true
Posted by: Guest on November-02-2020

Code answers related to "difference between equals method and == operator in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language