+ 1
What is difference between string and string literal?
2 Answers
+ 4
A "string literal" is a sequence of characters from the source character set enclosed in double quotation marks (" "). String literals are used to represent a sequence of characters which, taken together, form a null-terminated string.
https://stackoverflow.com/questions/3297867/difference-between-string-object-and-string-literal
https://www.sololearn.com/discuss/357807/?ref=app
0
n java, String can be initialized as Literal or Object.
String Literal
String a = âABCâ;
In this case a String is created in String pool. Now if I initialize
String b = âABCâ;
And put if condition - if (a==b) this would return true as both a and b point to one literal in pool
String object
String a = new String (âaâ);
String b = new String(âaâ);
If (a==b) returns false in this case as the references point to different objects and (a.equals (b)) returns true.
know more here on string:- http://crbtech.in/Java-Training/10-things-string-every-java-programmer-know/