问题标题:
Exceptioninthread"main"java.lang.ArrayIndexOutOfBoundsException:0atPoint.main(Point.java:15)publicclasspoints{protectedintx,y;publicpoints(){setPoint(0,0);}publicpoints(inta,intb){setPoint(a,b);}publicvoidsetPoint(inta,intb){x=a;y
问题描述:
Exceptioninthread"main"java.lang.ArrayIndexOutOfBoundsException:0atPoint.main(Point.java:15)
publicclasspoints{
protectedintx,y;
publicpoints(){setPoint(0,0);}
publicpoints(inta,intb){setPoint(a,b);}
publicvoidsetPoint(inta,intb){
x=a;
y=b;
}
publicintgetX(){returnx;}
publicintgetY(){returny;}
publicStringtoString()
{return"["+x+","+y+"]";}
}
但是运行的时候不对……就是一行上面的字
马欣艺回答:
这个异常是初学者比较常见的异常.ArrayIndexOutOfBoundsException:注意这个单词,字面意思就是数组引用超出界限,也就是我们常说的越界问题.比如,我们创建了一个数组inta[]=newint[4];那么数组a只能存放四个元素...
点击显示
其它推荐