我在为我的场景制作逻辑时遇到了困难,我正在考虑将阵列数组更具体地称为2D阵列。我想要在2D阵列中找到我不想调用的最大值它在主要方法。我做数组作为匿名,并通过静态数据成员从它调用最大的函数。代码如下。让我知道逻辑找到二维数组中最大的否定,因为我发现它很难到值与array.the代码进行比较如下: -阵列2D最大值的阵列
class Max2DArray
{
static int i;
static int j;
static int large;//largest number
int max(int x[][])
{
for(int i=0;i<x.length;i++)
{
for(j=0;j<x[i].length;i++)
{
if(x[i][j]<=???)//what should be the comparison here.
{
??//what should be done here??
}
}
}
return large
}
public static void main(String... s)
{
Max2DArray m1 = new Max2DArray();
int t = m1.max(new int[][]{{20,10,5},
{5,7,6},
{23,31,16}});
System.out.println("the largest number is = "+t);
}
}
也许你应该使用名为'large'的变量? (顺便说一下,'large'可能不应该是'static','i'和'j'不应该是字段。) – bradimus