Answers for "using collections in java"

1

import collections in java

import java.util.Collection;
Posted by: Guest on May-08-2020
0

how to define a collection in java

List<String> list = Arrays.asList("Lars", "Simon");
Posted by: Guest on October-30-2020
-2

when to use collections in java

When to use List, Set and Map?
If we need to access elements frequently by using index, then List is a way 
to go ArrayList provides faster access if we know index.
If we want to store elements and want them to maintain an order, 
then go for List again. List is an ordered collection and maintain order.
If we want to create collection of unique elements and don't want
any duplicate than choose any Set implementation. (HashSet... )
If we want store data in form Key and Value than Map is the way to go.
We can choose from HashMap, Hashtable...
Posted by: Guest on December-05-2020

Code answers related to "using collections in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language