Question Index

Write a program to remove element at given index by using one of the List interface methods.

Input (List, int) Output (List)
[Lion, Tiger, Cat, Rabbit, Mouse], 1 [Lion, Cat, Rabbit, Mouse]
[Rose, Jasmine, Lotus, Peacock, Cassia], 4 [Rose, Jasmine, Lotus, Peacock]
[1, 2, 3, 4, 5, 6], 9 null
[Red, Blue, Green, White, Black, Pink], -1 null
null, 2 null

import java.util.*;
class RemoveElementAtGivenIndex
    public static void main(String s[])
        LinkedList<String> input = new LinkedList<String>();
        System.out.println("The list after removed : " + removeElementAtGivenIndex(input, 4));


    public static List removeElementAtGivenIndex(LinkedList<String> input, int index) {




Topic: Java LinkedList

Read this topic
Take test on this topic

Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App