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?
4 Antworten
+ 2
It's implicit. Integer a[] = {1,2,3} compiles to: Integer a[] = new Integer[] {1,2,3}
+ 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.
+ 1
Thanks a lot Erik.
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.