How the reference types work ???? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How the reference types work ????

plz give answers with examples

19th Dec 2016, 10:33 AM
Prashant Malviya
Prashant Malviya - avatar
2 Answers
+ 1
Primitive types include int, double, float, char, boolean, long, byte, and short. Other data types (objects, mostly) are reference types. For example, the String type is a reference type. The variable that is assigned to the string contains a memory address (a complex sequence of digits consisting of numbers and letters) designates a place in memory for that String. Primitive types refer to their assigned value (e.g. int num = 10; //num refers to 10) whereas objects refer to a memory address. Memory addresses look similar to this: A@9304b1 Hope this helps!
19th Dec 2016, 8:37 PM
Scylla
Scylla - avatar
0
Great but is string type really reference ??? i don't think so. ... give me some code ... of string reference ...
20th Dec 2016, 2:22 AM
Prashant Malviya
Prashant Malviya - avatar