Javatpoint Logo
Javatpoint Logo

Java ListIterator previous() Method

The previous() method of ListIterator interface is used to return the previous element from the list and moves the cursor in a backward position. The above method can be used to iterate the list in a backward direction.

Syntax

Parameters

NA

Return

The above method is used to return the previous element of the given list.

Throws:

NoSuchElementException- If the given iteration has no such previous elements.

Example 1

Test it Now

Output:

The list of alphabets is given as : [88, 67, 57]
In the forward direction : 
88
67
57
In the backward direction:-
57
67
88

Example 2

Test it Now

Output:

The list of electrical appliances is given as : [Fan, Tubelight, Bulb, Television]
In the forward direction : 
Fan
Tubelight
Bulb
Television
In the backward direction:- 
Television
Bulb
Tubelight
Fan

Example 3

Test it Now

Output:

The list of alphabets is given as : [R, E, A, L]
In the forward direction : 
R
E
A
L
In the backward direction:- 
L
A
E
R





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA