+ 3

What is the difference between value type and reference type?

28th May 2017, 6:38 AM
Amandeep
Amandeep - avatar
3 odpowiedzi
+ 5
java passes types by value not reference. meaning a copy of the original value is made and you manipulate the copy, not the original value. reference type is usually done for objects (non primitives). when manipulating reference types, the original value is changed along with every change. hope that helps. :)
28th May 2017, 7:13 AM
Thanh Le
Thanh Le - avatar
+ 1
Value types go on the stack fully. Those are the number types. Objects are reference types. They have the useful information stored on the heap, and a reference to their heap address on the stack. Hence the name.
28th May 2017, 7:21 AM
1of3
1of3 - avatar
+ 1
Thank you guys ! i understand now.
28th May 2017, 7:37 AM
Amandeep
Amandeep - avatar