Menu
Question Index
...

What will be the output of the following program?

import java.util.*;

public class ListIterator
{
    public static void main(String args[])
    {
        List<Integer> list = new ArrayList<Integer>();
        java.util.ListIterator<Integer> listIterator = null;
        list.add(23);
        list.add(98);
        list.add(29);
        list.add(71);
        list.add(5);
        listIterator = list.listIterator();
        System.out.println("Elements in backward direction:");
        while(listIterator.hasPrevious())
        {
            System.out.println(listIterator.previous());
        }
    }
}


Elements in backward direction:
5
71
29
98
23
Elements in backward direction:
23
98
29
71
5
Elements in backward direction:
5
23
29
71
98
Elements in backward direction:
Compilation Error or Runtime Error

Doubts

Problems

Topic: List Iterator In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App