本文介绍了如何以编程方式在二维数组中插入值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在java中动态地做到这一点.我知道如何在单维数组中插入值.我对二维数组有点困惑.

I want to do this dynamically in java. I know how to insert values in single dimensional array. I am bit confused in two dimensional array.

static final String shades[][] = {


 // Shades of grey
  {
    "lightgrey", 
    "dimgray", 
    "sgi gray 92", 
  },
 // Shades of blue
  {
    "dodgerblue 2", 
    "steelblue 2", 
    "powderblue", 
  },
// Shades of yellow
  {
    "yellow 1",
    "gold 1",
    "darkgoldenrod 1", 
  },
 // Shades of red
  {
    "indianred 1", 
    "firebrick 1", 
    "maroon", 
  }
};

推荐答案

String[][] shades = new String[intSize][intSize];
 // print array in rectangular form
 for (int r=0; r<shades.length; r++) {
     for (int c=0; c<shades[r].length; c++) {
         shades[r][c]="hello";//your value
     }
 }

这篇关于如何以编程方式在二维数组中插入值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 05:30