Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException:0 at Point.main(Point.java:15)
问题描述:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException:0 at Point.main(Point.java:15)
public class points {
protected int x,y;
public points(){setPoint(0,0);}
public points(int a,int b){setPoint(a,b);}
public void setPoint(int a ,int b){
x=a;
y=b;
}
public int getX(){return x;}
public int getY(){return y;}
public String toString()
{return "[" +x+","+y+"]";}
}
但是运行的时候不对……就是一行上面的字
答
这个异常是初学者比较常见的异常.ArrayIndexOutOfBoundsException:注意这个单词,字面意思就是数组引用超出界限,也就是我们常说的越界问题.比如,我们创建了一个数组 int a[] = new int[4] ;那么数组a只能存放四个元素...