import collections in java
import java.util.Collection;
what is vector in java
Array based data structure/Internally uses
dynamic array.
-It is synchronized - thread safe.
-It is mostly used in multi-threaded environment.
-It is much slower than ArrayList because it is
thread-safe
collections in java
Any group of individual objects which are represented as a single unit is known as the collection of the objects. In Java, a separate framework named the “Collection Framework” has been defined in JDK 1.2 which holds all the collection classes and interface in it.
how to define a collection in java
List<String> list = Arrays.asList("Lars", "Simon");
what is collection fromework
The Java collections framework is a set of classes and interfaces that implement commonly reusable collection data structures.
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...
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us