- Task 1
Make an array of 5 integers.
Define the array, but don't assign anything to it.
- Task 2
Use a for loop to set the values of the array to the index plus 10.
To access the elemetns of the array, use the loop index, as in this example:
for(int i = 0; i < 5; i++) {
myarray[i] = 0;
}
- Task 3
Use a for loop to print out the values in the array.
To print a string, do this:
System.out.println("msg");
- Task 4
Make an array of strings initialized to Frank, Bob, and Jim using the variable initializer syntax.
The initalization expression should be:
{ "Frank", "Bob", "Jim" }
- Task 5
Use a for loop to print out the strings in the array.
This is similar to printing out integers.
- Task 6
Set the last element of the array to Mike.
The string literal here should be "Mike"
- Task 7
Print out the last element in the array.
The last index of an array is always one minus
the length of the array.