蒙圈了,求大神解决,
class Qq
{
public static void a(int[] bb)
{
for (int x=0;x<bb.length;x++)
{
for (int y=x+1;y<bb.length-x;y++)
{
if (bb[x]>bb[y+1])
{
int z=bb[x];
bb[x]=bb[y];
bb[y]=z;
}
}
}
}
public static void main(String[] args)
{
int[] bb={1,2,3,6,4,};
c(bb);
a(bb);
c(bb);
}
public static void c(int[] bb)
{
for (int x=0;x<bb.length;x++)
{
System.out.print(bb[x]+",");
}
}
}
打印完是这个样子的看不懂,大神给点指导
1,2,3,6,4,Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 5
at Qq.a(Qq.java:9)
at Qq.main(Qq.java:22)
|