Java Fundamentals  «Prev  Next»

Creating and Accessing an Array - Exercise

Creating and accessing an Array

Objective: Create and access an array.

Exercise Grading

This exercise is worth a total of 1 point.

Exercise instructions

Create a simple command-line application named FirstLast that creates and initializes an array of chars.
In the main() method of this application create an array of char called letters and initialize it with the letters in the word "object".
You will not need to use the String class in this exercise. Use System.out.println() to display the first and last elements in the array. Try not to use a constant for the index of the last element. Here is one possible way the output for this application could appear:
The first letter is 'o' and the last letter is 't'. After completing the exercise, click the Submit button and view the results page.