Question: 1 - Programming with Arrays and Strings Write a bit of Java code to perform each of the following tasks. 1. Declare an array called
1 - Programming with Arrays and Strings Write a bit of Java code to perform each of the following tasks. 1. Declare an array called colorNames and bind it to a string array of length 4. 2. Place the color names "red", "blue", "orange", "yellow" into the four elements of the array that you just established. 3. Imagine that a string valued parameterless method called getcolorName exists, and that it will randomly produce the name of a color when called. Write an assignment statement to replace the first element of the array of color names with the result of a call to the getcolorName method. 4. Introduce an appropriately typed variable called theColor and bind it to the contents of the first element of the array 5. Display, to the standard output stream, the number of letters in the color name to which the variable theColor is bound
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
