In: Computer Science
What are the values in arrays a, b, and c after the following code executes (list all of the elements of the arrays)?
double[] a = new double[4];
double[] b = {6,4,2};
a[a.length-1] = b[b.length-1];
double[] c = b;
c[0] = -1;
b[1] = c[2];
c = a;
c[0] = -2;
a[1] = c[3];
Please find the updated code below:::
package classes10;
public class Main {
public static void main(String[] args) {
double[] a = new double[4];
double[] b = {6,4,2};
a[a.length-1] =
b[b.length-1];
double[] c = b;
c[0] = -1;
b[1] = c[2];
c = a;
c[0] = -2;
a[1] = c[3];
System.out.println("Content of
array a is : ");
for(int
i=0;i<a.length;i++){
System.out.print(a[i]+" ");
}
System.out.println(" Content of
array b is : ");
for(int
i=0;i<b.length;i++){
System.out.print(b[i]+" ");
}
System.out.println(" Content of
array c is : ");
for(int
i=0;i<c.length;i++){
System.out.print(c[i]+" ");
}
}
}
output: