@@adityaghadge3957 : A separate object will be created in the string constant pool whose reference is pointed to it . But u can see the old value remains the same in the memory . It means it is not over ridden. So since that value is not overridden it is immutable .
When S1 = "hello" , in the string pool a value hello would be created and S1 will point to it. When S1.concat("world") is done and when you print S1 you would get the output as hello only and not as helloworld, when u do S1 = S1.concat("world"); and print S1, now you will get the output as helloworld because the value helloworld would be newly created in the string pool and S1 would point to that and not hello value anymore due to the equal sign (=). But even when you modify it like this .. the hello is not editted it's in the same place or memory . We just created a new value in new place or memory .. and pointed S1 to it. So the hello would be removed by Garbage collector automatically if it's not been used. This Garbage collection is done by jvm itself
you said strings can be collected by GC but its not the case when i searched on internet it says jvm does not allow GC to run in strings pool , can yo elaborate on this?
Str1='val'; Str='val2'; What happened when same name of string object have different value explain with reference diagram(like 3.58 th minute in this video)
Happy to see you again!
Awesome!!! Finally, someone explained simply what Garbage really is ))) Thank you
java is garbage
*Informative content* 👍👍
03:17 We want use «new» for different String variables that point different strings with the same text.
Welcome back neso academy
Enlightening!
Thank you for such an easy to follow explanation.
BEST COURSE EVER!!!
Btw your explanation is too good.
Thanks for giving such an adorble content.
thank you for this resource you created, its self explanatory.
Thank you for clarifying this.
I guess I misunderstood you on the last couple of videos and rush to conclusions. My bad.
great explanation!
I love you Neso Academy. ❤️
Quite helpful 🙂
awesome expainition
Welcome back❤️❤️❤️
Love you🤭 thank you 💛
Please upload java videos everyday.
thank you bro
Welcome back
thanks
Sir please make a playlist on servlet and jsp
Thankyou sir 😊
thank you sir
Thanks!
Sir App release date??
Strings are immutable its value cannot changed but how it changed when we concatenate it with other string pls explain with reference address box
Ya same doubt 🤔 please answer it !!!
@@adityaghadge3957 : A separate object will be created in the string constant pool whose reference is pointed to it . But u can see the old value remains the same in the memory . It means it is not over ridden. So since that value is not overridden it is immutable .
When S1 = "hello" , in the string pool a value hello would be created and S1 will point to it.
When S1.concat("world") is done and when you print S1 you would get the output as hello only and not as helloworld, when u do S1 = S1.concat("world"); and print S1, now you will get the output as helloworld because the value helloworld would be newly created in the string pool and S1 would point to that and not hello value anymore due to the equal sign (=).
But even when you modify it like this .. the hello is not editted it's in the same place or memory . We just created a new value in new place or memory .. and pointed S1 to it.
So the hello would be removed by Garbage collector automatically if it's not been used.
This Garbage collection is done by jvm itself
@@ManiKandan-vo2qr that seems inefficient memory-wise. can we erase that old value from memory?
@@hetaeramancer GC will automatically does that work
wallah habibi come to dubai
Great!!!
you said strings can be collected by GC but its not the case when i searched on internet it says jvm does not allow GC to run in strings pool , can yo elaborate on this?
That is incorrect.
Read - When will a string be garbage collected in java ? on Stackoverflow.
@@rajeshprajapati6662 can you provide some links ?
100th like 😄🥳💥
Str1='val';
Str='val2';
What happened when same name of string object have different value explain with reference diagram(like 3.58 th minute in this video)
Strings are immutable in java. So, you can not hold different values on the same name of the string.
GC is not applicable for string constant pool
Hey sir, String and constant are similar right, they cannot be change
It's clear , and how about prinitives data type ? Are Java primitives immutable?
no, if you assign a new value to an integer, the previous value will be overwritten and you will store the new value in the integer
String bhot easy h
Who are seeing in 2024
I think old value is not removed by Java Garbage Collector in the String Literal.
Data structures in C????
Alrrrrrrrright😂👍🏻
String is stored in String Constant Pool and java garbage collector can not remove the value stored in String Constant Pool
russian teacher h kya
😂
JAVA Garbage collector 🤣🤣🤣😅 Is that a real thing?