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();
        LinkedList input2 = new LinkedList();
        System.out.println("The matched elements are : " + getMatchedElements(input1, input2));


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




Topic: Java LinkedList

Read this topic
Take test on this topic

Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App