uniquity
05-13-2009, 06:49 AM
for my 102 class i have to create a LinkedList class that has to pass a given test driver. i've passed most things in the test but the test is getting stuck on a runtime exception that is thrown for one of the constructors. the constructor code is below, it takes in a List and adds its elements to the end of the ArrayList. if you need the test driver as well, that can be provided
public LinkedList( java.util.List<E> list )
{
head = null;
size = 0;
if( list.isEmpty() )
{
}
else
{
for( int ctr = 0; ctr < list.size(); ctr++ )
{
this.add( list.get( ctr ) );
size++;
}
}
}
The test driver also specifies that its an ArrayOutOfBoundsException, but i dont see where i would be going out of bounds with my code. thanks in advance for any help
public LinkedList( java.util.List<E> list )
{
head = null;
size = 0;
if( list.isEmpty() )
{
}
else
{
for( int ctr = 0; ctr < list.size(); ctr++ )
{
this.add( list.get( ctr ) );
size++;
}
}
}
The test driver also specifies that its an ArrayOutOfBoundsException, but i dont see where i would be going out of bounds with my code. thanks in advance for any help