pals i just wanna ask if anyone could show me how to declare and call a 2d array?

thanks in advance!!!

Recommended Answers

Piece of cake

int a[][] = new int[2][4];  Define and SetSize

You can google many example on 2D Array. Like http://leepoint.net/notes-java/data/arrays/arrays-2D.html

Jump to Post

All 3 Replies

Member Avatar

You can also pre-populate the 2D array upon creation.

int a[][] = { {1, 2, 3, 4}, {5, 6, 7, 8} };
int len_1 = a.length;  -- len_1 would be 2
int len_2 = a[0].length;  -- len_2 would be 4
int len_3 = a[1].length;  -- len_3 would also be 4

call a 2d array?

Can you explain what you mean by "call"? Arrays contain data, not methods.
They could contain object references to classes that have methods that could be called:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.