Several Arrays per Program

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
go to previous page   go to home page   go to next page

Answer:

double[] dvals = { 0.0, 0.5, 1.5, 2.0, 2.5 };

Several Arrays per Program

A program can have any number of arrays in it. Often values are copied back and forth between the various arrays. Here is an example program that uses two arrays:

class ArrayEg4
{
  public static void main ( String[] args )
  {
    int[] valA = { 12, 23, 45, 56 };

    int[] valB = new int[4]; 

     =  ;

     =  ;

     =  ;

     =  ;  

 
   }
}

QUESTION 12:

Fill in the blanks so that the values in valA are copied into the corresponding cells of valB.