Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

So my teacher is a plagerizer - Yet another DLL question

770463Nov 22 2010 — edited Nov 23 2010
So a while ago I asked about DLL's and making them. Well I should have waited till today to ask my question because the teacher managed to do an implentation using a dllnode class he wrote and the remove method. the code is bellow. Well its after class and theres an error and the instructor can't help and the assignment is due tomorrow.

"Wait how is he a plagerizer?" you'll see, look at linked list for this code >_<
//remove at said index

	@Override
	public E remove(int index) throws IndexOutOfBoundsException
	{
		
	 return remove(indexEntry(index));
}

// Find the next index value

private DllNode<E> indexEntry(int index)
	{
		if (index <0 || index > size)
		{
			throw new IndexOutOfBoundsException();
		}
		
		DllNode<E> element = header;
		
		if (index < (size >> 1))
		{
			for (int i = 0; i <= index; i++)
			{
				element = element.getNext();
			}
		}
		
		else
		{
			for (int i= 0; i > index; i--)
			{
				element = element.getPrev();
			}
		}
		return element;
	}
the error is on the remove method call. saying that i need to convert the indexEntry to int or place DllNode<E> with in the parameter for remove....

The teachers code is the same, his works, this code, upon further investigation is IDENTICLE to that of the linkedlist code for the java source.

any help as to why I am throwing this error?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 21 2010
Added on Nov 22 2010
36 comments
410 views