Java:如何从int [] []中获取单个int值

Dil*_*fey 8 java int extract

我有一个int [] []对象.它在我的代码中定义如下:

public int[][] position = {
    {20, 30}, {73, 91},
    {82, 38}
};
Run Code Online (Sandbox Code Playgroud)

是否有可能获得每对圆括号中第一个值(左侧)的值,并使用for循环将它们存储为单独的int变量?基本上,是否可以提取"20","73"和"82"并将它们分别存储到int变量中?

zie*_*mer 12

for(int[] x : position){
  int y = x[0];
  // Do something with y...
}
Run Code Online (Sandbox Code Playgroud)

要不就:

int x = position[0][0];
int y = position[1][0];
int y = position[2][0];
Run Code Online (Sandbox Code Playgroud)