initialize array java in class code example Example: initialize an array in java int[] array=new int[5]; int[] array2=new int[]{1,2};