class class2
{
public static void main(String[] args)
{
int d=0;
int[] x={5,6,9,6,45,12,32,58,98,7,95};
for(int i=1;i<=x.length;i++){
int q = x[i-1];
int w = x[i];
d = max(q,w);
}
System.out.println("最大的是 "+d);
}
public static int max(int z,int y){
if(z>y)
return z;
else
return y;
}
}
读取不报错,但是不能输出
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 11
|
|