Skip Top Navigation Bar

Write Code Segments that Require One-Dimensional Arrays

Your Turn

  • Write program code to complete the provided tasks.
  • Run the code in the Java Playground to see if your code generates the desired result.
  • Make necessary changes until you have satisfied the tasks.

Practice 1: Colors

  • Create a String[] array with "Red", "Green", "Blue". Print the color stored at index 1. Do not use an initializer list to create and assign values to this array.
  • Try the code in the Java Playground to verify your prediction.

Practice 2: Fall Months

  • Create a String[] array for the months of the year. Use an initializer list to set the value to the twelve months of the year. Print the last three months of the year as the fall months.
  • Try the code in the Java Playground to verify your prediction.

Practice 3: Setting Array Elements

  • Declare an int[] array of length 5. Assign the value 10 to the last position and print it.
  • Try the code in the Java Playground to verify your prediction.