Click here - / @interviewdot to get notifications. String Object String Literal Java
A Job Portal
http://www.InterviewDot.com http://www.InterviewDot.com http://www.InterviewDot.com
One Click Dream Job - http://www.interviewdot.com/upload-re...
Are you looking for a new Job ?
InterviewDot.com - A Job Portal
http://www.InterviewDot.com http://www.InterviewDot.com http://www.InterviewDot.com
One Click Dream Job - http://www.interviewdot.com/upload-re...
Difference between "String Literal" and "String Object" in Java ?
/STRING LITERAL
//-------------
//When you use a string literal the string can be "interned" but when you use new String
//you get a new string object.
//STRING OBJECTS
//--------------
//Here two different objects are created and they have different references:
//A String object is an individual instance of the java.lang.String class.
//In general you should use the string literal notation when possible.
//It is easier to read and it gives the compiler a chance to optimize your code.
//s1Str will refer to an interned String object. This means,
//that the character sequence "abcde" will be stored at a central place and whenever the same literal "abcde" is used again,
//the JVM will not create a new String object but use the reference of the 'cached' String.
//s2Str is guranteed to be a new String object,
String Object String Literal Java