This video will clear your concept on String Memory allocation. After watching this video, you will sure differentiate what is stack memory, heap memory and string constant pool. String Algorithms Data Structures and Algorithm Series
I have been learning Java for so long but the concept of string was not clear...But after this video I am able to understand the difference between string literal and string object..Thank you for sharing your knowledge in such a easy way
how is it even possible to learn Java for a long time and not to understand the difference between literal and object? how long do you learn java? :). just curious
The most easiest and detailed explanation of Strings I must say. This video of your's Harshal have cleared all my doubts regarding String and its memory allocation. It would be very helpful if you can explain with examples for the scenarios when to declare string with literals and when with new keyword.
Which book you refered sir for this topic...when you create string s5="Java" it store in constant pool area ,it will not refence with the new key object bcz it will stored in nonconstant pool area
What about the corner case if you make a new string s6, String s6 = new String("hello"), would that be made only in the heap space and ignored in the SCP?
Good Explanation, But Looks Wrong. Checked through many sites and ChatGPT , none of those agrees that the String Created with New Operator Creates 2 Objects. Pls attach source of Knowledge. (Just asking for Clarity of Concept) . Edit : Found some references that supports 2 Objects creation with New operator . Confused Now