如何在java中初始化2D数组中的一列?

时间:2015-11-04 12:20:02

标签: java arrays multidimensional-array

我是编码的新手,需要制作Yathzee游戏。我想在我的2D数组中只初始化一列,但找不到如何。

players = p;
    String[][] rnc= new String[21][p+1];

    for(int i = 0; i < 20; i++){
        for(int j = 0; j < p + 1; j++){
            rnc[i][0] = {"upper section", "ones", "twos", "threes", "fours", "fives", "sixes", "total", "bonus", "total w bonus", "lower section", 
                    "3 of a kind", "4 of a kind", "full house", "small straight", "large straight", "YATHZEE", "chance", 
                    "total lower section", "total upper section", "grand total"};

这得到一个“数组常量只能用于  初始化者“-error。

1 个答案:

答案 0 :(得分:1)

您可以使用辅助数组:

SELECT Invoice.*, Invoice_lines.* 
  FROM Invoice
  LEFT JOIN Invoice_lines ON Invoice.ID = Invoice_lines.Invoice
   ORDER BY Invoice.Display_order, Invoice_lines.Display_order