OCJA(1Z0 - 808)|| Important Conclusions about String Immutability

  Рет қаралды 25,479

Durga Software Solutions

Durga Software Solutions

Күн бұрын

Пікірлер: 32
@muninkumbhakar3887
@muninkumbhakar3887 2 жыл бұрын
Sir, this big concept got know after many years! thanks a lot!
@shubhamgaygol6737
@shubhamgaygol6737 Жыл бұрын
Sir in last example As For DURGA is a string constant so in SCP also object copy created
@Anonymous-sh8kc
@Anonymous-sh8kc 3 жыл бұрын
my doubt is, when you create String s2 = s1.lowerCase(); why it doesn't point to the object in SCP but it points to the object in Heap despite both are the same valued object. isn't SCP supposed to be searched first by JVM ? please explain Sir Respect from Canada.
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 3 жыл бұрын
Hello Friend. Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
@raghipandit6624
@raghipandit6624 Жыл бұрын
good question. I am wondering the same.
@Arun-zy8wi
@Arun-zy8wi Жыл бұрын
Great teacher ❤
@premabhisek
@premabhisek 5 жыл бұрын
Thanks for sharing. I just have 1 question in regards to the s1.toUpperCase() statement. Any new object that gets created during runtime, goes into heap area. However once any new string that gets created in heap, the same gets created in string constant pool too. If my understanding is correct, then once "DURGA" gets created in heap, will "DURGA" get created in SCP too?? Please correct me if I am wrong..
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 5 жыл бұрын
Hello Abhishek. Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
@rohitmehta3812
@rohitmehta3812 5 жыл бұрын
"DURGA" would be created under heap only because it gets created at runtime, if a new operator is used i.e String s=new String("DURGA"); then only objects would be created on heap as well as under SCP
@sandeepg5387
@sandeepg5387 4 жыл бұрын
Because we are not using String Literal(Constant) . We are calling a method at runtime. Hence it wont be created in SCP. Compiler will add string constants to SCP. Compiler wont able to predict the result of method call and hence it wont add SCP. Further, SCP is meant for string constants, hence the name String 'Constant" Pool.
@blesseddivya3935
@blesseddivya3935 2 жыл бұрын
Thank you Sir
@raghipandit6624
@raghipandit6624 Жыл бұрын
Why does s3 point to durga String in Heap area and not SCP area? Anyone? 7:01 timestamp
@raghipandit6624
@raghipandit6624 Жыл бұрын
I think it is because if there is no change in the object ( in s1.toLowerCase() ) then the existing object (that was initially created in Heap) is used. If s1 would have been created without the new keyword then s3 would have pointed to the object in SCP (object that gets created initially). Then both s1 and s3 would point to the same object in SCP. Make note that he says "If there is no change in the content then the existing object is used whether it is in Heap or SCP."
@raghipandit6624
@raghipandit6624 Жыл бұрын
I literally answered my own question lol
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions Жыл бұрын
Hello Friend. Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
@manikandand2541
@manikandand2541 4 жыл бұрын
wow sirji
@dilipgyawali1776
@dilipgyawali1776 4 жыл бұрын
String s1 = new String("durga"); String s2 = s1.toUpperCase(); String s3 = s2.toLowerCase(); System.out.println(s1==s2); System.out.println(s1==s3); what will happen in this case??? please explain.
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 4 жыл бұрын
Hello Dilip. Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
@gavravdhongadi9824
@gavravdhongadi9824 4 жыл бұрын
In the first like itself it will create an object in the heap as well as in SCP
@bhavyamadaan7109
@bhavyamadaan7109 4 жыл бұрын
Output: - False False Because According to the first line object is created in heap and scp S1->durga(heap) durga(scp) According to the 2nd line S2-> DURGA(HEAP) because object os created in heap at runtime Then the content of s2 is changing So new object will created in heap S3->durga
@sidhantsatapathy8603
@sidhantsatapathy8603 3 жыл бұрын
@@bhavyamadaan7109 right
@naseehashahjahan2266
@naseehashahjahan2266 3 жыл бұрын
false true
@krishnamoorthi1549
@krishnamoorthi1549 2 жыл бұрын
private void doubt() { String s1= new String ("you cannot change me"); String s2 = "you cannot"; String s3 = s2+"change me"; System.out.println(s1==s3);//false //case1 // sir first new key word s1 object create in heap area and scp area //s3 = "you cannot change me" create in run time it not pointing into s1 heap area object but same content String s4 = new String("durga"); String s5 = s4.toLowerCase(); System.out.println(s4==s5);//true //case2 //sir s4 object is create in two area heap and scp area ok // s5 = s4.toLowerCase();this is run time operation ok because of that object is create in heap area // s5 is pointing into s4 because of same content you said that in case1 s1 content and s3 content is also same then //why it not pointing into same object why i got false in answer
@DurgaSoftwareSolutions
@DurgaSoftwareSolutions 2 жыл бұрын
Hello Krishna. Plz contact our online team durgasoftonlinetraining@gmail.com or call us on this number +918885252627, 7207212427/28
@krishnamoorthi1549
@krishnamoorthi1549 2 жыл бұрын
ok sir i sent a message to this mail id thanks for our replay sir thanks sir
@krishnamoorthi1549
@krishnamoorthi1549 2 жыл бұрын
@@DurgaSoftwareSolutions sir i have sent mail to this id please replay to my mail sir
@kananm5491
@kananm5491 2 жыл бұрын
@@DurgaSoftwareSolutions sir i also have this doubt please clarify that doubt
@ravim7606
@ravim7606 2 жыл бұрын
@@DurgaSoftwareSolutions sir I also have this doubt please clarify that
OCJA(1Z0 - 808)|| Creation of Our Own Immutable Class
11:43
Durga Software Solutions
Рет қаралды 38 М.
OCJA(1Z0 - 808)|| Important Methods of String class: trim() method and its use case
23:23
А что бы ты сделал? @LimbLossBoss
00:17
История одного вокалиста
Рет қаралды 10 МЛН
Seja Gentil com os Pequenos Animais 😿
00:20
Los Wagners
Рет қаралды 47 МЛН
This dad wins Halloween! 🎃💀
01:00
Justin Flom
Рет қаралды 15 МЛН
🕊️Valera🕊️
00:34
DO$HIK
Рет қаралды 12 МЛН
Why String is Immutable and Final in Java?
19:59
Naveen AutomationLabs
Рет қаралды 88 М.
#35 Mutable vs Immutable String in Java
6:23
Telusko
Рет қаралды 138 М.
Why string is immutable in java || The 4 reasons you must know || part 1
20:53
What is String Immutable || Why String Object Is Immutable In Java (Hindi)
17:36
OCJA(1Z0 - 808) || Need of StringBuilder and differences with StringBuffer
11:47
Durga Software Solutions
Рет қаралды 13 М.
Java Strings are Immutable - Here's What That Actually Means
7:06
Coding with John
Рет қаралды 618 М.
А что бы ты сделал? @LimbLossBoss
00:17
История одного вокалиста
Рет қаралды 10 МЛН