• Post Reply Bookmark Topic Watch Topic
  • New Topic

Multydimensional Arrays  RSS feed

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ???
 
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!