Saturday 30 March 2019

What is the difference between implicit and explicit String declaration in java?

For Example..





String herName = new String("clark");



and



String hisName = "michal";



1) The first piece of code exactly does, it will create new string
object in the heap memory with reference .




2) The second line of code , its an string literal which create
string object in string constant pool, not in actually heap memory.




Then what's the benefit, ?

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...