I made one class for my object:
public class circles {
int coor_x;
int coor_y;
int ray;
public circles(int coor_x, int coor_y, int ray) {
this.coor_x=coor_x;
this.coor_y = coor_y;
this.ray =ray ;
}
public int getCoor_x() {
return coor_x;
}
public int getCoor_y() {
return coor_y;
}
public int getRay() {
return ray;
}
public void setCoor_x(int coor_x){
this.coor_x=coor_x;
}
public void setCoor_y(int coor_y){
this.coor_y=coor_y;
}
public void setRay(int ray){
this.ray=ray;
}
}
But when I wont to make an array of it and fill it with a for, with this code:
int coor_x=2;
int coor_y=2;
int ray=2;
int i = 0;
circles circles_test[]=new circles[10];
for(i=0; i<=circles.length;){
circles_test[i]=new circles(coor_x, coor_y, ray+i); //line 30
System.out.println("Ray of circles: "+circles_test[i].getRay());
i++;
}
it works but with errors: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 10 at circlesObjectCreator.main(circlesObjectCreator.java:30) Java Result: 1
What I am doing wrong? Is a better why to it? Please help and thank you.
for(i=0; i<circles.length;)
– zengr Oct 6 '11 at 21:37