Menu
Question Index
...

Write a program to reverse elements by using one of the Collections interface methods.

Input (LinkedList) Output (LinkedList)
[Cricket, Chess,Hockey, Foot Ball] [Foot Ball, Hockey, Chess, Cricket]
['A', 'B', 'C', 'D', 'E', 'F'] [F, E, D, C, B, A]
[1, 2, 3, 4, 5, 6] [6, 5, 4, 3, 2, 1]
[0.1f, 1.2f, 0.9f, 10.2f, 16.1f, 12.1f] [12.1, 16.1, 10.2, 0.9, 1.2, 0.1]
null null


import java.util.*;
class ReverseTheElements
{
    public static void main(String s[])
    {
        LinkedList input = new LinkedList();
        input.add("Java");
        input.add("C++");
        input.add("C");
        input.add(".Net");
        input.add("Oracle");
        System.out.println("The elements after reversing : " + getReverseElements(input));

    }


    public static LinkedList getReverseElements(LinkedList input) {
    }

}

Doubts

Problems

Topic: Java Collection Algorithms

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App