Menu
Question Index
...

Write a program to get the matched elements from the given inputs by using one of List interface methods.

Input (LinkedList, LinkedList) Output (LinkedList)
[Terns, Skimmers, Skuas, Sandgrouse, Pigeons, Barbets], [Terns, Pigeons, Barbets] [Terns, Pigeons, Barbets]
[Rose, Jasmine, Lotus, Peacock, Cassia], [Rose, Peacock, Jasmine, Lotus, Orchid] [Rose, Jasmine, Lotus, Peacock]
[Revanth, Sashi, Kalyan, Kishore, Ashok], [Ashok, Sashi, Mani] [Sashi, Ashok]
[Mercedes, Audi, Ferrari, BMW, Ford], null null


import java.util.*;
class GetMatchedElements
{
    public static void main(String s[])
    {
        LinkedList input1 = new LinkedList();
        input1.add("One");
        input1.add("Two");
        input1.add("Three");
        input1.add("Four");
        input1.add("Five");
        LinkedList input2 = new LinkedList();
        input2.add("One");
        input2.add("Three");
        input2.add("Five");
        System.out.println("The matched elements are : " + getMatchedElements(input1, input2));

    }


    public static LinkedList getMatchedElements(LinkedList input1, LinkedList input2) {
    }

}

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