Access the array java program


Discuss the below:

Q: Access the array 4 Java program. Code, compile, and run the program. There are four lines of code marked (1)..(4) that you must explain after analyzing the code, running the program, and examining the output.

import java.io.*;

public class array4 //class code block
{
public static final double value1 = 25.5; //class variable

public static void main(String args[]) throws IOException //method code block of class
{

int x,y;
int max = 20;
double a,b;
int[] ints1 = new int[max]; //creates array of integers (1)

System.out.println(ints1[0]); //array elements initialized to zero
x = 25;
y = 15;
ints1[0]= x++ + y++; // (2)
System.out.println(x);
System.out.println(y);
System.out.println(ints1[0]); //value is 40 and is precedence dependent

for(int i=0;i {
ints1[i]=i+2; // (4)
System.out.println(ints1[i]);
}
System.out.println(ints1[4]+value1);

}
}

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Access the array java program
Reference No:- TGS01935902

Now Priced at $20 (50% Discount)

Recommended (90%)

Rated (4.3/5)