Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create Multidimensional array?

I want to create multidimensional array which has levels, groups and items.

like image 580
Horrorgoogle Avatar asked Aug 05 '11 06:08

Horrorgoogle


People also ask

What is the multidimensional array?

A multi-dimensional array is an array with more than one level or dimension. For example, a 2D array, or two-dimensional array, is an array of arrays, meaning it is a matrix of rows and columns (think of a table).

How can you create a multidimensional array in PHP?

You create a multidimensional array using the array() construct, much like creating a regular array. The difference is that each element in the array you create is itself an array. For example: $myArray = array( array( value1 , value2 , value3 ), array( value4 , value5 , value6 ), array( value7 , value8 , value9 ) );

How do you declare a 3 dimensional array in Java?

Examples: Two dimensional array: int[][] twoD_arr = new int[10][20]; Three dimensional array: int[][][] threeD_arr = new int[10][20][30];


1 Answers

Why not create an array of your custom defined objects?

class A{
    int t;
    int b;
}

List<A> test = new ArrayList<A>();
test.add(new A());
like image 109
Esben Skov Pedersen Avatar answered Oct 19 '22 23:10

Esben Skov Pedersen