Perfect explanation for an important topic. Even in some university lectures, the professors can't explain these things like you do. I already knew these things but the way you tell about them is just impressive. Thanks for your efforts. Great work.
please note that non-primitive types do not store their values in stack they only store the reference in the stack and that reference will be connected to a random part inside "heap" , the heap will contain the value of that reference
Thank you so much for this! I have always said that boxes makes my learning easier, and in this case it was definitely true. I have been struggling to understand how reference types work in Java and this video made me understand it.
public class Program { public static void main(String[] args) { String s1="hello"; String s2=s1; s2="hi"; System.out.println(s1); System.out.println(s2); } }. The output is : hello, hi sir why the output is different as they reference the same String “hello”
Because you reassigned the value of s2. While they were both assigned to the same value, they could point to the same object in memory. But since s2 was reassigned to a different value, it had to point to a different object in memory.
I just take the course outline from my class and look for corresponding videos on NESO Academy. My professor knows I don’t show up to class and wonders how I can still pass my exams and hw 😂
Thank you very much for the explanation, I wanted to ask you for advice recently I wanted to learn how to create apps with flutter and the language it uses is dart and it's oo like java do you think I should learn java first then dart or it's best learn dart straight away?
when you instantiate a variable of type string, a string variable or container will be allocated in the memory that stores the reference of the value at the same time the value of the variable will be created in the heap memory.
Why is that i1 and i2 have different values as you mentioned in the last part. of video. In my view, they do have different adresses which make i1 and i2 are different. But they do have same value, because i2 is assigned value 5 from i1.
I tried this in IntelliJ with a string and didn't work. I created 2 strings and assigned the 1st to the 2nd. Then I changed the value of s1 and printed both strings, but s2 did not change. program: _____________________________________________ String s1 = "hello"; String s2 = s1; System.out.println(s1); System.out.println(s2);
justpaulo when you stored S1 inside of S2 it’s like you made a copy of the (S1 “hello”;) inside of S2. Later on if you change the value of S1 it will not change S2
This was the best explanation of Reference types I've ever watched. This was awesome. Thank you
You are the greatest teacher ( who teach us free on RUclips ) ,ever in the youtube , for teaching java . 😍
Perfect explanation for an important topic. Even in some university lectures, the professors can't explain these things like you do. I already knew these things but the way you tell about them is just impressive. Thanks for your efforts. Great work.
Crisp, clear, to the point!!
Hats off Neso Academy for making learning so efficient!
At the end of every video u say Thanks for watching 😊 but I have to say Thank you 😊 for making this tutorial...
Really Helpful 🙏
please note that non-primitive types do not store their values in stack they only store the reference in the stack and that reference will be connected to a random part inside "heap" , the heap will contain the value of that reference
The reference address is stored in the stack(which contains the address/pointer) and its contents in the heap?
@@farzin818 yes
This is really best lecture on primitive and reference types.Nobody can explain like this.Thankyou sir for this amazing series🔥🔥🔥🔥🔥😊
Have been struggling with the idea of reference variable and this amazing videos clear my doubts!!!
Thank you so much for this! I have always said that boxes makes my learning easier, and in this case it was definitely true. I have been struggling to understand how reference types work in Java and this video made me understand it.
gj man. Why cant university teachers explain it like this
U r the world's best teacher sir😍😍
My teacher is refering this vid and presenting it, Thank You!
You're amazing teacher. I watched few movies on RUclips and I don't understood nothing. Thanks!!!.
Energetic explanation that helps to understand the concept
What a clear explanation!! You saved my time!! I appreciate it
The best explanation ever....
The best explanation ever
Thank u very very much ......I'm suffering from this confusion for 1 month.
Hello friend, is it possible for us to study together because I am not good at Java and cannot study on my own. Can we cooperate together?
@@سيليناالمززززز ok
@@bringmygroozaaop5864 fatima_khaleel001 my insta
public class Program
{
public static void main(String[] args) {
String s1="hello";
String s2=s1;
s2="hi";
System.out.println(s1);
System.out.println(s2);
}
}. The output is : hello, hi sir why the output is different as they reference the same String “hello”
Because you reassigned the value of s2. While they were both assigned to the same value, they could point to the same object in memory. But since s2 was reassigned to a different value, it had to point to a different object in memory.
I watch so many videos and you are the best , I really understood the topic
You are a life saver man. Big ups!
primitive should me named ---> expresion type. amd all would be clear and understable :) Thank you man ! this was very good explaination
thank u so much! i was struggling to understand the difference but u explained it really well
The accent made it even more intresting.
Really great explanation and was very clear and on point. Thank You :)
you are explaining with Abbreviated and awesome way 👍👏
Best explanation,I am very clear about this now tq so much sir
This made things so much clear. Thank You!
The best explanation I have seen 👏 👌
thankyo for clear explanation my teacher and i appreciate you millions times
Bahut sahi sir ❤️🔥
Nice explanation
Excellent class as usual
the best explanation
Hello friend, is it possible for us to study together because I am not good at Java and cannot study on my own. Can we cooperate together?
Great explanation. One question, why is important to know memory location etc..theory what is Refrence types vs Primitive types?
This was the best explanation. I like it.
I just take the course outline from my class and look for corresponding videos on NESO Academy. My professor knows I don’t show up to class and wonders how I can still pass my exams and hw 😂
Thank you so much you explained it so easily
I love you Neso Academy. ❤️
thank you soo much its so well explained good continuation
Thanks for making such conceptual videos.
Thank you very much for the explanation, I wanted to ask you for advice recently I wanted to learn how to create apps with flutter and the language it uses is dart and it's oo like java do you think I should learn java first then dart or it's best learn dart straight away?
If you just want to build apps I’d use dart, most oop languages carry the same logic with different syntax
yes yes thank! for your video help in me to understand my teacher lesion.
Great Explaination.
Thank You.
Excellent explanation!!
Thanks for the explanation... ✨
Amazingly done! Hats off
This is an amazing explanation!
very simple and objective
Best explanation !!! Thank You
nice concept u share;
Nicely expained. Thank you so much
Fantastic video, thank you!
Thank You, Radha Radha
great explination
Great explanation!
Awesome. But we are waiting for reamainder video in c programming and data structure series. Please sir make reamainder video as soon as possible.
Thanks
thank you thank you thank you THANK YOU !
Great explanation. keep it up!
A great explanation....
Excellent
Very clear, thank you my friend)
Thanks for this informative videos!
Thankyou
Very good job
5:30 How "hello" is getting stored in the memory without declaring a variable or a container?
when you instantiate a variable of type string, a string variable or container will be allocated in the memory that stores the reference of the value at the same time the value of the variable will be created in the heap memory.
Sir, can't wait to witness the neso aap !!!how much more will I have to wait???
very good explaination!
really good! thank you!!!
Thank you!
thank you sir
thanks man,finaly i catch it ❤
Hello friend, is it possible for us to study together because I am not good at Java and cannot study on my own. Can we cooperate together?
ونصيحه وانتي بتشوفي الدبلومه حلي problem solving في موقع hackerrank بالتوازي مع الدبلومه
شكرا كثير
Great video
thank you so much
thank you so much !
amazing video!!!
thank u so much bro
Perfect!!
super
Thank u
🙌wonderful
habibi tum nice explain karti
I want a playlist on advanced data structures
through c++
THANKS ALOTTTTTT
legend
great!!!
the best...
Love it
Sir ye wala nhi smjh aaya aur sb aa gya
perfect explains but alittle fast .
Sir How to get a variables memory address, can you give me code to it
Sir why reference type directly not store a value instead of storing a address of the value?? Pls clear my doubt?
Hmm 🤔 interesting
Why is that i1 and i2 have different values as you mentioned in the last part. of video. In my view, they do have different adresses which make i1 and i2 are different. But they do have same value, because i2 is assigned value 5 from i1.
as they both stored in different addresses makes the values different.
Why s2 not containing the address of s1? Why not s2 = s1 address?
strong
I tried this in IntelliJ with a string and didn't work.
I created 2 strings and assigned the 1st to the 2nd. Then I changed the value of s1 and printed both strings, but s2 did not change.
program:
_____________________________________________
String s1 = "hello";
String s2 = s1;
System.out.println(s1);
System.out.println(s2);
s1="bye";
System.out.println(s1);
System.out.println(s2);
Output:
_______________________________________________
hello
hello
bye
hello
_______________________________________________
justpaulo when you stored S1 inside of S2 it’s like you made a copy of the (S1 “hello”;) inside of S2. Later on if you change the value of S1 it will not change S2
Because String class is immutable
@@b_b_d_b is there a way where i can change s1 using s2?
thanks my Egyptian friend
How to make reference variable of int?????