Top "Collections" questions

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

How can I initialise a static Map?

How would you initialise a static Map in Java? Method one: static initialiser Method two: instance initialiser (anonymous subclass) or …

java dictionary collections initialization idiomatic
How to initialize HashSet values by construction?

I need to create a Set with initial values. Set<String> h = new HashSet<String>(); h.…

java collections constructor initialization hashset
How do I remove repeated elements from ArrayList?

I have an ArrayList<String>, and I want to remove repeated strings from it. How can I do …

java list collections arraylist duplicates
How to convert a Map to List in Java?

What is the best way to convert a Map<key,value> to a List<value>? Just …

java list collections map
Converting 'ArrayList<String> to 'String[]' in Java

How might I convert an ArrayList<String> object to a String[] array in Java?

java arrays string arraylist collections
Is there a short contains function for lists?

I see people are using any to gather another list to see if an item exists in a list, but …

python list search collections contains
How to convert an Array to a Set in Java

I would like to convert an array to a Set in Java. There are some obvious ways of doing this (…

java collections arrays set
Getting an element from a Set

Why doesn't Set provide an operation to get an element that equals another element? Set<Foo> set = ...; ... Foo …

java collections set equals
What is the best way to filter a Java Collection?

I want to filter a java.util.Collection based on a predicate.

java collections filter
How do I remove an array item in TypeScript?

I have an array that I've created in TypeScript and it has a property that I use as a key. …

arrays typescript collections