Quantcast
Viewing all articles
Browse latest Browse all 50

How to Test String Equality in Java ?

Sample program to test String Equality in Java using equals to (==) operator and String.equals() method. public class StringEqualsTest { public static void main(String[] args) { String str1 = "hello"; String str2 = str1; String str3 = new String("hellp"); String str4 = new String("hello 2"); String str5 = "hello"; System.out.println("Comparison using == : " + […]

Viewing all articles
Browse latest Browse all 50

Trending Articles