My array has total 10 indices and I'm trying to set array[0] = 1/1, array[1] = 1/2, array[2] = 1/3, array[4] = 1/4 and so on.
After the calculation I want to display the elements with Sytem.out.println();
What am I doing wrong?
public static void main(String[] args) {
final int VALUE =1;
int[] array = new int[10];
int counter=10;
double result =0;
for(int i =0; i<array.length; i++)
{
array[0]=VALUE/i;
array[1]=VALUE/i;
array[2]=VALUE/i;
array[3]=VALUE/i;
array[4]=VALUE/i;
array[5]=VALUE/i;
array[6]=VALUE/i;
array[7]=VALUE/i;
array[8]=VALUE/i;
array[9]=VALUE/i;
System.out.println( array[0] +" " + array[1] +" " + array[2] +" " + array[3]+" " + array[4]+" "+array[5]+" " +array[6] +" " + array[7]+" " + array[8]+" " + array[9]+" " + array[10]);
}
}
array[i] = VALUE/i;array[0]=VALUE/i;does? What aboutarray[1]=VALUE/i;, etc? What will they do differently each time through the loop?