Question: public class FirstList { private final int DEFAULT_SIZE=10; private int currentItem=0; private T arList[]; @SuppressWarnings(unchecked) public FirstList() { // arList=new T[DEFAULT_SIZE]; arList=(T[]) new Object[DEFAULT_SIZE]; }

public class FirstList

{

private final int DEFAULT_SIZE=10;

private int currentItem=0;

private T arList[];

@SuppressWarnings("unchecked")

public FirstList()

{

// arList=new T[DEFAULT_SIZE];

arList=(T[]) new Object[DEFAULT_SIZE];

}

@SuppressWarnings("unchecked")

public FirstList(int length)

{

// arList=new T[length]; //causes a compile error

arList=(T[]) new Object[length];

}

// writes a setter called addItem //Write code to add an item to the end of the array

}

1. Write a setter for FirstList.java 2. Examine the solution in FirstListSol.java 3. Write getters for FirstListSol.java (Watch array bounds! Do you need to catch an error?) 3. Now: Create your ListApp class. 4. Write a square class. Write a 3d point class with x,y,z integer coordinates. Make sure they have a toString() method. 5. Make three lists in your App class, a list of Strings, a list of Squares and a list of Points. 6. Iterate your lists and print out the items.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!