You are not logged in. Please login at www.codechef.com to post your questions!

×

Java Collections Tutorial Part - 2

In the previous tutorial, we have seen the introduction to JCF and Iterators. In this tutorial, lets look into the details of Collection Interfaces and Classes.

THE COLLECTION INTERFACES

The Collection Classes implementing these interfaces have the functionality of these interfaces. Therefore, these interfaces define the core behavior of a Collection class.

alt text

THE COLLECTION ABSTRACT CLASSES

The Abstract Classes provide skeletal implementations that are used as starting points for creating concrete Collections.

alt text

THE COLLECTION CLASSES

These standard classes provide full implementation of the Collection that can be used as-is.

The below table shows various differences between the Collection classes. The terms used in the table are -

1) AD - Allow Duplicates: It tells whether that particular collection allows duplicate values to be inserted.

2) AN - Allow Null: It tells whether null objects can be inserted into that particular collection.

3) Inserted Order: It tells whether the objects are stored in the same order in which they were inserted.

4) Sorted Order: It tells whether the objects are stored in sorted order.

5) Synchronized: It tells whether the collection is thread-safe or not.

6) Random Access: It tells whether the collection has a get() method to returns the index of an object or return the object using an index.

7) Default capacity: The initial capacity of the collection when it is created using an empty constructor.

alt text

The Time Complexities of basic operations are given below:

alt text

Click here to go to next tutorial


Java Collections Tutorial Series:

Java Collections Tutorial Part - 1

Java Collections Tutorial Part - 2

Java Collections Tutorial Part - 3

Java Collections Tutorial Part - 4

asked 05 Nov '16, 08:53

kay_kay's gravatar image

4★kay_kay
1.2k721
accept rate: 20%

edited 17 Nov '16, 23:39


Keep up the effort! There are few materials for java in competitive programming and from my experience, it is really a great language due to the Collections framework.This will definitely benefit school programmers who are just getting started as java is way more common , at least in Indian schools:)

link

answered 17 Nov '16, 23:43

rajarshi_basu's gravatar image

6★rajarshi_basu
6287
accept rate: 10%

Good. That's great. Carry on.

link

answered 09 Dec '16, 20:34

rashedcs's gravatar image

2★rashedcs
49751755
accept rate: 4%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×1,302
×706
×160
×81
×68
×35

question asked: 05 Nov '16, 08:53

question was seen: 2,605 times

last updated: 09 Dec '16, 20:34