Menu
Question Index
...

Write a program to get the unique strings list from the given input list. The order of the strings should be in the same order as the input list.

Input (Strings List) Output (Unique Strings List)
["A", "B", "A", "C", "Z", "M", "K", "Z"] ["A", "B", "C", "Z", "M", "K"]
["Y", "B", "L", "Z", "R", "K"] ["Y", "B", "L", "Z", "R", "K"]
[EMPTY LIST] [EMPTY LIST]
["S", "S", "S", "S", "S", "S"] ["S"]
["M", "E", "R", "I", "T", "C", "A", "M", "P", "U", "S"] ["M", "E", "R", "I", "T", "C", "A", "P", "U", "S"]


import java.util.List;
import java.util.ArrayList;
class GetUniqueStringsList
{
    public static void main(String s[])
    {
        List<String> letters = new ArrayList<String>();
        letters.add("A");
        letters.add("B");
        letters.add("A");
        letters.add("C");
        letters.add("Z");
        letters.add("M");
        letters.add("K");
        letters.add("Z");
        
        List<String> uniqueLetters = getUniqueStringList(letters);
        
        System.out.println("Before removing duplicates : " + letters);
        System.out.println("After removing duplicates : " + uniqueLetters);

    }


    public static List<String> getUniqueStringList(List<String> inputList)
    {
    }

}

Doubts

Problems

Topic: Java ArrayList

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App