COLLECTIONS FRAMEWORK Introduction

COLLECTIONS:

  • Collection is an object that represents a groups of objects.
  • The Java collections framework provides a set of interfaces and classes to implement various data structures and algorithms.
  • Collection is a heterogeneous.
  • It helps to overcome the disadvantages in array.

Some disadvantages of array:

Occupies continuous memory. Unused memory is wasted.Data manipulation is bit difficult.

FRAMEWORK:

  • A framework is a set of classes and interfaces which provide a ready-made architecture.

Advantages of Collection Framework:

  • Reduces programming effort by providing data structures and algorithms so you don’t have to write them yourself.
  • Increases performance by providing high-performance implementations of data structures and algorithms. Because the various implementations of each interface are interchangeable, programs can be tuned by switching implementations.(tbd)
  • Reduces the effort required to learn APIs

api – application programing interface- already have classes we can use them.

Collection FrameWork consist of :

COLLECTION INTERFACE:

jdk does not provide any direct implementation of its collection interfaces but provides implementation of subinterfaces like Set,List.

  • The collection interfaces are divided into two groups. They are Collection and Map
  • The most basic interface is java.util.Collection and other one is java.util.Map.
java.util.Collection consist of subinterfaces(tbd) like
  • List, Set, Queue etc

List:

  • insertion Ordered collection.
  • duplicate values are allowed.

Set:

  • no duplicate is allowed.
  • no order is maintained.

list–> ArrayList, LinkedList (tbd)

set–> Hashset, LinkedHashSet, TreeSet (tbd)

java.util.Map

MAP:

  • A map contains values on the basis of key, i.e. key and value pair. Each key and value pair is known as an entry. A Map contains unique keys.
  • key + value — entry
  • key keyset, value – collection of values, entry- entryset (tbd)

map-> HashMap , LinkedHashMap, TreeMap. (tbd)

Why the Collections Framework?

  • The Java collections framework provides various data structures and algorithms that can be used directly.
  • We do not have to write code to implement these data structures and algorithms manually.

The collections framework allows us to use a specific data structure for a particular type of data.(tbd).

  • If we want our data to be unique, then we can use the Set interface provided by the collections framework.
  • To store data in key/value pairs, we can use the Map interface.
  • The ArrayList class provides the functionality of resizable arrays.

REFERENCES:

https://www.geeksforgeeks.org/collections-in-java-2/ https://docs.oracle.com/javase/8/docs/technotes/guides/collections/overview.html https://www.programiz.com/java-programming/collections https://www.javatpoint.com/collections-in-java

Leave a comment

Design a site like this with WordPress.com
Get started