How to create Multidimensional array?
I want to create multidimensional array which has lev开发者_StackOverflow社区els, groups and items.
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());
To create Multidimensional array in static way,
Ex:
static final String listdesc[][][][] =
{
{ // grey
{ // lightgray
{ "grey", "grey only" },
{ "lightgrey","#D3D3D3" },
{ "dimgrey","#696969" }
},
{ // darkgray
{ "grey", "darkgrey" },
{ "sgi grey 92","#EAEAEA" }
}
},
{ // blue
{ // lightblue
{ "blue", "lightblue" },
{ "dodgerblue 2","#1C86EE" }
},
{ // darkblue
{ "blue", "darkblue" },
{ "steelblue 2","#5CACEE" },
{ "powderblue","#B0E0E6" }
}
},
{ // yellow
{ // lightyellow
{ "yellow", "lightyellow" },
{ "yellow 1","#FFFF00" },
{ "gold 1","#FFD700" }
},
{ // darkyellow
{ "yellow", "darkyellow" },
{ "darkgoldenrod 1","#FFB90F" }
}
},
{ // red
{ // lightred
{ "red", "lightred" },
{ "indianred 1","#FF6A6A" }
},
{ // darkred
{ "red", "darkred" },
{ "firebrick 1","#FF3030" },
{ "maroon","#800000" }
},
}
};
To create it programatically, refer to,
Assign data to a four Dimensional Array at RunTime
精彩评论