Iterate through the linkedlist is like this: -
LinkedList<Integer> ll = new LinkedList<Integer>();
Iterator<Integer> itr = ll.iterator();
while (itr.hasNext()) {
int val = itr.next();
}
Question is how to unit test(eg: if elements are 1, 2, 3, 4 in sequence is the unit test case, or example a sortLinkedList function, etc.) such collections where only way to loop through them is through Iterator ? Also please refrain from giving solutions that involve Guava.