Menu
Question Index
...

Write a program to insert given element at top by using one of the Queue interface methods.

Input (ArrayDeque, String) Output (ArrayDeque)
[Lion, Tiger, Cat, Rabbit, Mouse], 'Bat' [Bat, Lion, Tiger, Cat, Rabbit, Mouse]
[Rose, Jasmine, Lotus, Peacock], 'Cassia' [Cassia, Rose, Jasmine, Lotus, Peacock]
[1, 2, 3, 4, 5, 6], '9' [9, 1, 2, 3, 4, 5, 6]
[Ferrari, BMW, Mercedes, Audi, Ford], null null


import java.util.*;
class InsertElementAtTop
{
    public static void main(String s[])
    {
        ArrayDeque<String> input = new ArrayDeque<String>();
        input.add("Ramesh");
        input.add("Sujan");
        input.add("Ravi");
        input.add("Ramu");
        input.add("Krishna");
        System.out.println("The elements after inserted: " + insertElementAtTop(input, "Mohan"));

    }


    public static ArrayDeque insertElementAtTop(ArrayDeque<String> input, String element) {
    }

}

Doubts

Problems

Topic: Java ArrayDeque Class

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App