Created
August 25, 2019 11:33
-
-
Save gauravkukade/55e93858fd88e8e3856bd108721016dd to your computer and use it in GitHub Desktop.
A java program to compare the reference of the strings. We use '==' operator to check the reference equality. Visit the detailed article about Java String pool and 'intern()' method https://coderolls.com/java-string-pool-and-intern-method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A java program to compare the reference of the strings. | |
* We use '==' operator to check the reference equality. | |
* | |
* @author Gaurav Kukade at coderolls.com | |
* | |
*/ | |
public class StringReferenceCompare { | |
public static void main(String[] args) { | |
String firstString = "coderolls"; | |
String secondString = "coderolls"; | |
System.out.println(firstString == secondString); //true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment