Find Us On: Facebook Twitter Rss Feed Blog
Need To Register? Sign Up Login

Java - IterableList

dickersonka
dickersonka 


For this assignment you will write a generic array-base list class called IterableList that implements Java's built-in Iterable interface. In addition to the methods required by the Iterable interface, you class must include the methods indicated below. You do not need to include error checking (ie. your methods don't need to throw exceptions). void add(int index, E e) - Adds element e at index position index void add(E e) - Adds element e to the end of the list E get(int index) - Returns the element at index position index E remove(int index) - Removes and returns the element at index position index Attachments
Tags Clarifications

Answers

Java - IterableList - Solution

dickersonka
dickersonka 



Attached is the solution to the Java - IterableList assignment including source and comments Attachments
IterableList.zip (1 K) Download

Preview
public E remove(int index){ //get element E removed = arr[index]; //loop through array for(int i=index; i<size; i++){ //shift elements down in array arr[i] = arr[i + 1]; } //decrement size size--; //return element return removed; }

Preview
3"); System.out.println(list.get(3)); //remove by index System.out.println("Remove index 0"); System.out.println(list.remove(0)); System.out.println("Remove index 3"); System.out.println(list.remove(3)); //print list printList(list); //insert at beginning of list System.out.println("Insert 1 at index 0"); list.add(0, 1); //insert at end of list System.out.println("Insert 5

IterableList_output.png (9 K) Download Preview

Screenshots
Screenshot
Purchase Answer