Top "Collections" questions

Collections APIs provide developers with a set of classes and interfaces that make it easier to handle collections of objects.

Collectors.toMap() keyMapper -- more succinct expression?

I'm trying to come up with a more succinct expression for the "keyMapper" function parameter in the following Collectors.toMap() …

java collections lambda java-8 java-stream
Difference between Arrays.asList(array) and new ArrayList<Integer>(Arrays.asList(array))

What is the difference between 1.List<Integer> list1 = new ArrayList<Integer>(Arrays.asList(ia)); //copy 2.List&…

java list collections
Identify duplicates in a List

I have a List of type Integer eg: [1, 1, 2, 3, 3, 3] I would like a method to return all the duplicates eg: [1, 3] What …

java collections
How to randomize two ArrayLists in the same fashion?

I have two arraylist filelist and imgList which related to each other, e.g. "H1.txt" related to "e1.jpg". …

java list collections arraylist
Change priorityQueue to max priorityqueue

I have priority queue in Java of Integers: PriorityQueue<Integer> pq= new PriorityQueue<Integer>(); When I …

java collections priority-queue
Why doesn't java.util.Set have get(int index)?

I'm sure there's a good reason, but could someone please explain why the java.util.Set interface lacks get(int …

java data-structures collections set
Converting List<Integer> to List<String>

I have a list of integers, List<Integer> and I'd like to convert all the integer objects into …

java string collections integer
Best implementation for Key Value Pair Data Structure?

So I've been poking around with C# a bit lately, and all the Generic Collections have me a little confused. …

c# data-structures collections
Big-O summary for Java Collections Framework implementations?

I may be teaching a "Java crash-course" soon. While it is probably safe to assume that the audience members will …

java collections big-o
Collections.emptyList() vs. new instance

In practice, is it better to return an empty list like this: return Collections.emptyList(); Or like this: return new …

java collections empty-list