By candid | Posted :
Nov 24, 2015
| Updated :
Nov 24, 2015
String Object
In string object new keyword will be used to create an object, the object will be created in Heap memory and its reference will be pointed to String pool.
String s1=new String("Candid");
String Literal
In String literal the referance will be directly refered to String Pool, refer the below diagram.
String s2="Candid";
To verify s1 and s2 are refering two different places use == to check it.
System.out.println(s1==s2); // returns false
To verify s1 and s2 are refering same value "Candid" use their hashcode function