Exercises - 1 - Arrays - Exercises
Exercises - 1 - Arrays - Exercises
PROGRAMMING EXERCISES
b) int n = 20;
int[] val = new int[n/5];
d) double i = 5;
int[] num = new int[val.length *2];
a) line[3];
b) line[0]
c) line [1+2];
d) line [line[2]];
e) line [line [3] – line[1]];
f) line[4];
PROGRAMMING EXERCISES:
1. (a) Create a new Java application called FirstArrays.
(c) Write a comment above the line indicating how many values and what type of data is stored in
the array.
(d) Write a statement that will assign a value of 8 to the 8 th element in the array.
(g) Write a comment above the for statement to explain what the loop does.
(h) Create a similar loop that displays all the elements of the array, along with their value as follows:
2. Create a project called Word Array that stores the following words in an array of size five (5):
• Cool
• Awesome
• Programming
• Java
• Class
Then ask the user for a word and check if that word exists in the array. If it does, print “Match was
Found!”, otherwise tell the user “The word is not in the array”. You will need to use the
equalsIgnoreCase() method.