« first day (583 days earlier)      last day (2365 days later) » 

2:04 PM
In this exercise you’ll get a chance to improve our expanding array to add some of the other functionality that you get in ArrayList.

You should add three methods:

public void add(int index, int element)
public int remove(int index)
public int size()
there's 2 files
1. Expanindgarray.java public class ExpandingArray
{
private static final int STARTING_SIZE = 10;
private int[] arr;
private int currentSize;
private int numElements;

public ExpandingArray()
{
arr = new int[STARTING_SIZE];
currentSize = STARTING_SIZE;
numElements = 0;
}

// Remove the element at index `index` and shift
// all subsequent elements to the left.
public int remove(int index)
{
// your code here
and there's a tester
public class ArrayTester extends ConsoleProgram
{
public void run()
{
ExpandingArray arr = new ExpandingArray();

for(int i = 0; i < 100; i++)
{
System.out.println("adding " + i);
arr.add(i);
}

for(int i = 0; i < 100; i++)
{
System.out.println(arr.get(i));
}

}
}
resetted the code for you guys so its easier
question is
In this exercise you’ll get a chance to improve our expanding array to add some of the other functionality that you get in ArrayList.

You should add three methods:

public void add(int index, int element)
public int remove(int index)
public int size()
 
 
8 hours later…
10:06 PM
6 messages moved from Java
1 message moved from Java
 

« first day (583 days earlier)      last day (2365 days later) »