Java数组的对象数组

时间:2011-12-18 06:42:32

标签: java arrays multidimensional-array

这就是我在伪代码中所需要的:

myArray = {
    {Object, Object, Object},
    {Object, Object, Object},
    {Object, Object, Object},
    {Object, Object, Object},
    {Object, Object, Object},
}

如何在真正的Java中声明和初始化这样的东西?

1 个答案:

答案 0 :(得分:3)

就像这样...

Object[][] myArray = {
    {obj11, obj12, obj13},
    {obj21, obj22, obj23},
    {obj31, obj32, obj33},
    {obj41, obj42, obj43},
    {obj51, obj52, obj53},
};

另请参阅Oracle's array tutorial