0

What is reference type?

Can anyone please explain what reference type is in java, exactly how it works and is array also a reference type data structure in java?

13th Feb 2017, 2:12 PM
Ratnadeep Dey
Ratnadeep Dey - avatar
4 Respuestas
+ 2
It's implicit. Integer a[] = {1,2,3} compiles to: Integer a[] = new Integer[] {1,2,3}
13th Feb 2017, 10:04 PM
Erik Verduin
Erik Verduin - avatar
+ 1
There are primitives (such as int) that store a value, and reference types (such as String) that store the addresses of the objects they refer to. All arrays in Java are references. There is an implicit "new" when you initialize an array.
13th Feb 2017, 4:01 PM
Erik Verduin
Erik Verduin - avatar
+ 1
Thanks a lot Erik.
14th Feb 2017, 3:35 AM
Ratnadeep Dey
Ratnadeep Dey - avatar
0
If all arrays are initialized with "new" keyword then how does this following piece of code works Integer a[]= {1,2,3}; without using a "new" keyword.
13th Feb 2017, 8:32 PM
Ratnadeep Dey
Ratnadeep Dey - avatar