C:\users\default>java ArrayEg2 cell 3: 0.0 cell 2: 2.98 cell 1: 1.43
Here is a more complicated example:
public class ArrayEg3
{
public static void main ( String[] args )
{
double[] val = new double[4];
val[0] = 1.5;
val[1] = 10.0;
val[2] = 15.5;
int j = 3;
val[j] = val[j-1] + val[j-2]; // same as val[3] = val[2] + val[1]
System.out.println( "val[" + j + "] == " + val[j] );
}
}
What does the above program print out?