Assume the following method is within the KWLinkedList class, what does the following method do? public boolean undefined( ) { ListIterator iter1 = iterator( ); ListIterator iter2 = iterator(size - 1); if (Iter1.hasNext() && iter2.hasPrevious()) { if( iter1.next().equals (iter2.previous()) return true; else return false; } } If the last two elements of the list are equal, then the method will return true, else it will return false. If the first element of the list is same as the last element of the list, then the method will return true else it will return false. If the list is same in the forward and reverse direction, then the method will return true, else it will return false. If the first two elements of the list are equal, then the method will return true, else it will return false.
Assume the following method is within the KWLinkedList class, what does the following method do?
public boolean undefined( )
{
ListIterator<E> iter1 = iterator( );
ListIterator<E> iter2 = iterator(size - 1);
if (Iter1.hasNext() && iter2.hasPrevious())
{
if( iter1.next().equals (iter2.previous())
return true;
else
return false;
}
}
-
If the last two elements of the list are equal, then the method will return true, else it will return false.
-
If the first element of the list is same as the last element of the list, then the method will return true else it will return false.
-
If the list is same in the forward and reverse direction, then the method will return true, else it will return false.
-
If the first two elements of the list are equal, then the method will return true, else it will return false.
Step by step
Solved in 2 steps