如何创建多维数组?

时间:2011-08-05 06:49:58

标签: android multidimensional-array

我想创建具有关卡,组和项目的多维数组。

2 个答案:

答案 0 :(得分:11)

为什么不创建自定义对象的数组?

class A{
    int t;
    int b;
}

List<A> test = new ArrayList<A>();
test.add(new A());

答案 1 :(得分:4)

以静态方式创建多维数组

前:

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" }
      },

    }
};

要以编程方式创建它,请参阅

Assign data to a four Dimensional Array at RunTime