Home » Java ListIterator hasPrevious() Method with Examples

Java ListIterator hasPrevious() Method with Examples

by Online Tutorials Library

Java ListIterator hasPrevious() Method

The hasPrevious() method of ListIterator interface is used to retrieve and remove the head of the deque. The method may differ by poll() method only in one case that it throws an exception if the given deque is empty.

Syntax

Parameters

NA

Return

The above method is used to return true if the given list iterator contains more number of elements during traversing the list in the reverse direction.

Example 1

Test it Now

Output:

In actual order :  22  44  88  11  33  In reverse order :  33  11  88  44  22  

Example 2

Test it Now

Output:

In actual order :  N  I  T  I  N  In reverse order :  N  I  T  I  N  

Example 3

Test it Now

Output:

The given string in actual order :  Java  is  a  platform  independent  language  The given string in reverse order :  language  independent  platform  a  is  Java  

You may also like