This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Java in General and the fly likes Multydimensional Arrays Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Multydimensional Arrays" Watch "Multydimensional Arrays" New topic
Author

Multydimensional Arrays

Aruna Balasuriya
Ranch Hand

Joined: Nov 14, 2009
Posts: 44
class A{}
public class B {

public static void main(String[] args) {

A[] a1 = new A[1];
A[][] a2 = new A[2][1];
a2[0] = a1;


}

}

Here a2[0] is it points to a1 array or it contains the value that a1 has ???
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19232

Multidimensional arrays are nothing more than arrays of arrays, and an array is in the end still an object. Therefore, you merely have another reference to the same array object. So yes, it points to a1 and nothing is copied.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Multydimensional Arrays
 
Similar Threads
How many Objects are elligible for Gabbage Collection at Line 17?
Garbage Collection (Cyclic references) Also known as Object Island
exam lab gc question
passing arrays
Errors in the K&B bonus exam?