class that accepts duplicates and sorts input automatically

I know that The Treeset Sort the input automatically but don't accept duplicates.Is there any class Collection in java that allows Duplicate values or objects and Sort the given Input

Answers


User List Implementation and sort them using Collection.sort()

List<String> list=new ArrayList<String>();
    list.add("A");
    list.add("C");
    list.add("A");
    list.add("B");
    list.add("A");

    System.out.println(list);
    Collections.sort(list);
    System.out.println(list);

But if you are using you object in collection then Implement Comparable interface and override compare(Object obj,Object obj1) method.

Otherwise you can write your Comparator then pass it to sort method.


List, along with Collection.sort() would fit your needs.


Need Your Help

Is it possible to move the "box" of a checkbox?

html css

Currently when you make a checkbox, the "box" is to the left of the text. Is it possible to adjust the orientation for:

Is there a way to let Applescript type what you say?

macos applescript speech

I think I'm not doing this right, this is what I have...