i'm working in java arrays, and i get this exception
java.lang.IndexOutOfBoundsException:Index: 0, Size: 0
here is my code :
public static void main(String[] args) {
setData();
}
public static void setData() {
try {
Product[] products = null;
int size = getSize();
for(int i = 0; i < size; i++) {
products = new Product[i];
if(products.length > 1) {
products[i].setId(i);
}
}
} catch(Exception e) {
System.out.println(e.getMessage());
}
}
so, what's wrong ?