Is there a quicker, more efficient means of doing so than using a ListIterator?
ListIterator<Integer> itr = list.listIterator(list.size());
while(itr.hasPrevious()){
System.out.println(itr.previous());
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Depending on the implementation of the
ListandListIteratorthe following may be (slightly) quicker.This may be faster for an
ArrayListbut it will almost certainly be slower for aLinkedList.Your best bet is to just use the iterator.
It is almost certain that whatever work you are doing in the loop will negate any performance gained by not using the iterator.