import java.util.*;
public class BinaryTest {
public static void main(String[] args) {
//declare array here
int size = 1;
for(int i = 0; i<=size; i++){
Integer[] iarray = new Integer[i];
if(size <= 64){
for(int j = 0; j<=(size-1)*2; j++){
iarray[j] = j*2;
size++;
}
}
System.out.println("Element at index " + i + ": " + iarray[i]);
}
}
}
I wanna print the array from sizes from 0 to 64 and print it with number in it. It gives me an: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0 at BinaryTest.main(BinaryTest.java:19) So is there a way I can solve this?