Menu
Question Index
...

Write a program to add the given element at given index.Use one of the List interface methods.

Input (List, String, int) Output (LinkedList)
[Lion, Tiger, Cat, Rabbit, Mouse], 'Owl', 1 [Lion, Owl, Tiger, Cat, Rabbit, Mouse]
[Suman, Sekhar, Rohan, Sukumar, Praneeth, Prakash], 'Jeevan', 0 [Jeevan, Suman, Sekhar, Rohan, Sukumar, Praneeth, Prakash]
[1, 2, 3, 4, 5, 6], '7', 9 null
[Red, Blue, Green, White, Black, Pink], 'Orchid', -1 null
null null


import java.util.*;
class AddElementAtIndex
{
    public static void main(String s[])
    {
        LinkedList<String> input = new LinkedList<String>();
        input.add("Java");
        input.add("C++");
        input.add("C");
        input.add(".Net");
        input.add("Oracle");
        System.out.println("The elements afetr inserted : " + addElementAtGivenIndex(input, "Sql", 5));

    }


    public static LinkedList addElementAtGivenIndex(LinkedList<String> input, String elemet, int index) {
    }

}

Doubts

Problems

Topic: Java LinkedList

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App