Question: Use Eclipse, create a new project called ArrayLabs. Create a class named ArrayDecs . Write the all of the declarations below: Provide an instance variable
Use Eclipse, create a new project called ArrayLabs.
Create a class named ArrayDecs. Write the all of the declarations below:
Provide an instance variable declaration for each off the names in the following list. Include and initial value specification that associates the name with an appropriately constructed array. For example, to declare usStates as a name that could refer all 50 states:
String[] usStates = new String[50];
Declaration for cityPopulation, an array that holds the current population of the 20 largest cities in the world
Declaration for squad, array used to refer to 11 players on a cricket team
Declaration for planets, an array used to represent the nine planets (including Pluto).
Init with the names of the planets
Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus, Neptune, Pluto.
I need the code for the above using eclipse.
I am sending you the sample code for the reference
import java.util.Arrays; public class SampleArrays { public static void main(String[] args) { // TODO Auto-generated method stub String[] thisIsAStringArray = new String[5]; thisIsAStringArray[0] = "AAA"; thisIsAStringArray[1] = "BBB"; thisIsAStringArray[2] = "CCC"; thisIsAStringArray[3] = "DDD"; thisIsAStringArray[4] = "EEE"; System.out.println( " A Simple Array Created by Assignment" ); System.out.println( thisIsAStringArray[0] ); System.out.println( thisIsAStringArray[1] ); System.out.println( thisIsAStringArray[2] ); System.out.println( thisIsAStringArray[3] ); System.out.println( thisIsAStringArray[4] ); // System.out.println( " Error - outside range" ); // System.out.println( thisIsAStringArray[5] ); System.out.println( " A Simple Array Created on Declaration" ); String[] thisIsAStringArray2 = {"FFF", "GGG", "HHH", "III", "JJJ"}; System.out.println( thisIsAStringArray2[0] ); System.out.println( thisIsAStringArray2[1] ); System.out.println( thisIsAStringArray2[2] ); System.out.println( thisIsAStringArray2[3] ); System.out.println( thisIsAStringArray2[4] ); // System.out.println( " Error - outside range" ); // System.out.println( thisIsAStringArray2[5] ); System.out.println( " A Simple Array Created by New Operator" ); String[] thisIsAStringArray3 = new String[]{"KKK", "LLL", "MMM", "NNN", "OOO"}; System.out.println( thisIsAStringArray3[0] ); System.out.println( thisIsAStringArray3[1] ); System.out.println( thisIsAStringArray3[2] ); System.out.println( thisIsAStringArray3[3] ); System.out.println( thisIsAStringArray3[4] ); // System.out.println( " Error - outside range" ); // System.out.println( thisIsAStringArray3[5] ); System.out.println( " A Simple Array Created After Initialiazation" ); boolean fruits = true; String[] thisIsAStringArray4; if (fruits) { thisIsAStringArray4 = new String[] {"Apple", "Banana", "Orange"}; } else { thisIsAStringArray4 = new String[] {"Asparagus", "Carrot", "Tomato"}; } System.out.println( thisIsAStringArray4[0] ); System.out.println( thisIsAStringArray4[1] ); System.out.println( thisIsAStringArray4[2] ); System.out.println( " Initialize Resets" ); thisIsAStringArray4 = new String[] {"Asparagus", "Carrot", "Tomato"}; System.out.println( thisIsAStringArray4[0] ); System.out.println( thisIsAStringArray4[1] ); System.out.println( thisIsAStringArray4[2] ); System.out.println( " Determine Length" ); System.out.println( thisIsAStringArray.length ); System.out.println( thisIsAStringArray4.length ); System.out.println( " Iterate Through Array" ); for( int i = 0; i < thisIsAStringArray4.length; i++) { String element = thisIsAStringArray4[i]; System.out.println( element ); } System.out.println( " Add an Element to an Array" ); String[] tempArray = new String[ thisIsAStringArray4.length + 1 ]; for (int i=0; i please send me the correct code.Don't send me the same sample code. Its just for reference.
with declaration and intial value associated with name and print it with the value
;>
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
