English 中文(简体)
• 如何分配A Value To The First Index In a Multi Aspectsal Array In Java
原标题:How To Assign A Value To The First Index In a Multi Dimensional Array In Java
  • 时间:2011-11-04 21:28:53
  •  标签:
  • java

我有2个阵列,我想知道,如果我的阵列如此,你如何确定第一个价值。

int array[a][b] = int[10][10];

你们如何在休闲过程中获得指数。

这是我最简单的法典,我正在预先努力。

int[][] timesTable = new int[12][12];

for(int i = 0; i < timesTable.length; i++){
    timesTable[i][i] = i + 1;//can t set the first index with this value
    System.out.println(timesTable[i]);
}
最佳回答

我希望你不会把“a”和“b”放在阵列宣言中。

int array[][] = int[10][10];

2D阵列是阵列。 指数“a”或你试图确定的内容是另一个阵列。

 timesTable[i][i] = i + 1;//can t set the first index with this value

以上内容可以这样写:

timesTable[i] = {1,2,3};// puts another array at index i
问题回答

您可使用<条码>。

如果你只是试图确定第一个要素,那么你可以做到:

array[0][0] = 100; // some number

如果你想对整个2个阵列的每一部分进行消旋,那么你就需要2个 lo,每个方面需要一个 lo,例如:

for ( int i = 0; i < array.length; ++i ) {
    for ( int j = 0; j < array[i].length; ++j ) {
        array[i][j] = i + j; // or whatever you want to set the elements to
        System.out.println( array[i][j] );
    }
}




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签