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.
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.
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
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.
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?
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.
Thank you sir for the explanation, it was very well done! I have a question but feel free to not answer it. In the reference type example you gave, you give us two variables "s1" and "s2". "s1" references the address location of the object string "hello" that is 1008 right? but in the case of "s2" it references the VALUE of "s1" not the address location of it, so that would make "s2" a primitive type because it references the value instead of the directory no? what if "s2" put in its value the address location of "s1" so that then that can take it to the "s1" value and since now the "s1" value is the string location "hello", the program finally take us to the string location "hello". is that possible?
Both s1 and s2 references to the address location of the value which is 1008. None of them are referencing an actual value. About the second part, Java doesn't behave that way because if you have n Strings then it would take a lot of runtime complexity to get to the actual value, so referencing to the actual value address is just straightforward.
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 UA-cam ) ,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.
At the end of every video u say Thanks for watching 😊 but I have to say Thank you 😊 for making this tutorial...
Really Helpful 🙏
Crisp, clear, to the point!!
Hats off Neso Academy for making learning so efficient!
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.
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
U r the world's best teacher sir😍😍
gj man. Why cant university teachers explain it like this
The best explanation I have seen 👏 👌
My teacher is refering this vid and presenting it, Thank You!
Energetic explanation that helps to understand the concept
You're amazing teacher. I watched few movies on UA-cam and I don't understood nothing. Thanks!!!.
I watch so many videos and you are the best , I really understood the topic
Nice explanation
What a clear explanation!! You saved my time!! I appreciate it
You are a life saver man. Big ups!
Thanks for the explanation... ✨
thank u so much! i was struggling to understand the difference but u explained it really well
Really great explanation and was very clear and on point. Thank You :)
Thanks for making such conceptual videos.
I love you Neso Academy. ❤️
you are explaining with Abbreviated and awesome way 👍👏
thankyo for clear explanation my teacher and i appreciate you millions times
The best explanation ever....
This is an amazing explanation!
This was the best explanation. I like it.
Best explanation,I am very clear about this now tq so much sir
Great explanation!
Thanks for this informative videos!
Amazingly done! Hats off
Bahut sahi sir ❤️🔥
Great Explaination.
Thank You.
nice concept u share;
The best explanation ever
primitive should me named ---> expresion type. amd all would be clear and understable :) Thank you man ! this was very good explaination
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
This made things so much clear. Thank You!
Excellent class as usual
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.
very simple and objective
thank you soo much its so well explained good continuation
Very good job
A great explanation....
Thank you so much you explained it so easily
Very clear, thank you my friend)
Excellent explanation!!
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?
yes yes thank! for your video help in me to understand my teacher lesion.
Great explanation. keep it up!
great explination
Fantastic video, thank you!
Best explanation !!! Thank You
Nicely expained. Thank you so much
very good explaination!
🙌wonderful
Excellent
amazing video!!!
thank you thank you thank you THANK YOU !
Great explanation. One question, why is important to know memory location etc..theory what is Refrence types vs Primitive types?
The accent made it even more intresting.
really good! thank you!!!
thank you so much !
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 بالتوازي مع الدبلومه
شكرا كثير
Sir, can't wait to witness the neso aap !!!how much more will I have to wait???
Great video
thank you so much
thank u so much bro
Perfect!!
thank you sir
Thank you!
Thanks
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?
If you just want to build apps I’d use dart, most oop languages carry the same logic with different syntax
Awesome. But we are waiting for reamainder video in c programming and data structure series. Please sir make reamainder video as soon as possible.
Thankyou
super
Thank u
great!!!
Thank You, Radha Radha
Love it
THANKS ALOTTTTTT
the best...
Sir why reference type directly not store a value instead of storing a address of the value?? Pls clear my doubt?
Hmm 🤔 interesting
habibi tum nice explain karti
Sir How to get a variables memory address, can you give me code to it
I want a playlist on advanced data structures
through c++
legend
like like 👍🏻👍🏼
Why s2 not containing the address of s1? Why not s2 = s1 address?
💥💥💥💫
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.
How to make reference variable of int?????
Thank you sir for the explanation, it was very well done! I have a question but feel free to not answer it.
In the reference type example you gave, you give us two variables "s1" and "s2". "s1" references the address location of the object string "hello" that is 1008 right? but in the case of "s2" it references the VALUE of "s1" not the address location of it, so that would make "s2" a primitive type because it references the value instead of the directory no?
what if "s2" put in its value the address location of "s1" so that then that can take it to the "s1" value and since now the "s1" value is the string location "hello", the program finally take us to the string location "hello". is that possible?
Both s1 and s2 references to the address location of the value which is 1008. None of them are referencing an actual value. About the second part, Java doesn't behave that way because if you have n Strings then it would take a lot of runtime complexity to get to the actual value, so referencing to the actual value address is just straightforward.
thanks my Egyptian friend
🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻👍👍👍👍👍👍👍👍