Page 1 of 9
[Link] Package Tutorial
Java - [Link] Package
The [Link] package is a standard package of Java SDK. It contains the collections framework, legacy collection
classes, event model, date and time facilities, internationalization, and miscellaneous utility classes. This
package is very useful as it provides commonly used Collections like ArrayList, HashMap, Set etc. [Link]
provides StrinTokenizer classes for String operations and similarly other utility classes for event model handlings,
date and time operations and lot more. This reference will take you through simple and practical methods
available in [Link] package.
Importing [Link] Package
Being an inbuilt package of Java, we're not required to download any external library for [Link] package and its
all classes can be imported using following syntax:
import [Link].*;
Here we've used * operator to import all classes from [Link] package and now any class can be used in the
program. In case of specific class, for example ArrayList, we can import a class using following syntax:
import [Link];
Why [Link] Package is used in Java Programs
Powered by:
[Link] package classes contains utility classes like collections frameworks, String operations utilities, Date and
Time operations utilities. Following list shows some of the categories of classes of [Link] package.
00:00
Page 2 of 9
Collections − ArrayList, HashMap, Dictionary are few of the classes of large set of Collection classes
availble in [Link] package. These classes provides commonly used operations on large data sets.
Date Time Operations − GregorianCalendar, Timezone are some of the classes of utility classes availble
in [Link] package. These classes provides commonly used operations on date and time.
String Manipulations − StringTokenizer is an important utility class availble in [Link] package. This
class provides a lot of operations to manipulate strings.
Enumerations − Enumeration class of [Link] package provides operations on set of values like
iterations, comparison etc.
Exceptions − [Link] package contains various commonly occuring exceptions like
ConcurrentModificationException, InputMismatchException etc.
Important classes in [Link] Package
Following is the list of important classes in [Link]:
ArrayDeque − This class provides resizable-array and implements the Deque interface. This class and its
iterator implement all of the optional methods of the Collection and Iterator interfaces.
ArrayList − This class provides resizable-array and implements the List interface. The ArrayList class
extends AbstractList and implements the List interface. ArrayList supports dynamic arrays that can grow
as needed.
Arrays − This class contains a static factory that allows arrays to be viewed as lists. The ArrayList class
contains various methods for manipulating arrays (such as sorting and searching).
BitSet − This class creates a special type of array that holds bit values. The BitSet array can increase in
size as needed. This makes it similar to a vector of bits. This is a legacy class but it has been completely
re-engineered in Java 2, version 1.4. The Java BitSet class implements a vector of bits that grows as
needed. Powered by:
Calendar − This class is an abstract class that provides methods for converting between a specific
instant in time and a set of calendar fields such as YEAR, MONTH, DAY_OF_MONTH, HOUR, and so on,
and for manipulating the calendar fields, such as getting the date of the next week.
00:00
Page 3 of 9
Collections − This class consists exclusively of static methods that operate on or return collections.
Currency − This class represents a currency. The Currency class is designed so that there's never more
than one Currency instance for any given currency, this is the reason behind no public constructor.
Date − This class represents a specific instant in time, with millisecond precision.
Dictionary − This class is the abstract parent of any class, such as Hashtable, which maps keys to
values.
EnumMap − This class is a specialized Map implementation for use with enum keys. All of the keys in an
enum map must come from a single enum type that is specified, explicitly or implicitly, when the map is
created.
EnumSet − This class is a specialized Set implementation for use with enum keys. All of the keys in an
enum set must come from a single enum type that is specified, explicitly or implicitly, when the set is
created.
Formatter − This class provides support for layout justification and alignment, common formats for
numeric, string, and date/time data, and locale-specific output.
GregorianCalendar − This class is a concrete subclass of Calendar and provides the standard calendar
system used by most of the world. It is a hybrid calendar that supports both the Julian and Gregorian
calendar systems with the support of a single discontinuity, which corresponds by default to the
Gregorian date when the Gregorian calendar was instituted.
HashMap − This class is the Hash table based implementation of the Map interface.
HashSet − This class implements the Set interface, backed by a hash table.
HashTable − This class implements a hashtable, which maps keys to values.
IdentityHashMap − This class implements the Map interface with a hash table, using reference-equality
in place of object-equality when comparing keys (and values).
LinkedHashMap − This class is Hash table and Linked list implementation of the Map interface, with
predictable iteration order.
LinkedHashSet − This class is Hash table and Linked list implementation of the Set interface, with
predictable iteration order.
LinkedList − This class operations perform we can expect for a doubly-linked list. Operations that index
into the list will traverse the list from the beginning or the end, whichever is closer to the specified index.
ListResourceBundle − This class is an abstract subclass of ResourceBundle that manages resources for
a locale in a convenient and easy to use list.
Locale − This class object represents a specific geographical, political, or cultural region.
Observable − This class represents an observable object, or "data" in the model-view paradigm. The class
can be subclassed to represent an object that the application wants to have observed.
PriorityQueue − This class is an unbounded priority queue based on a priority heap. The elements of the
priority queue are ordered according to their natural ordering, or by a Comparator provided at queue
Powered by:
construction time, depending on which constructor is used.
Properties
Home − This class is a
Whiteboard classCompilers
Online which represents a persistent
Practice set of properties.
Articles Tools The Properties can be
saved to a stream or loaded from a stream.
PropertyPermission − This class is a class for property permissions.
Chapters 00:00 Categories
Page 4 of 9
PropertyResourceBundle − This class is a concrete subclass of ResourceBundle that manages resources
for a locale using a set of static strings from a property file.
Random − This class instance is used to generate a stream of pseudorandom numbers. The class uses a
48-bit seed, which is modified using a linear congruential formula.
ResourceBundle − This class contain locale-specific objects. The class allows you to write programs that
can be easily localized, or translated, into different languages.
[Link] − This class collaborates with the factory methods for loading resource
bundles.
Scanner − This class is a simple text scanner which can parse primitive types and strings using regular
expressions.
ServiceLoader − This class is a simple service-provider loading facility. Service loaders always execute in
the security context of the [Link] system code should typically invoke the methods in this class,
and the methods of the iterators which they return, from within a privileged security context.
SimpleTimeZone − This class is a concrete subclass of TimeZone that represents a time zone for use
with a Gregorian calendar.
Stack − Stack is a subclass of Vector that implements a standard last-in, first-out stack. Stack only
defines the default constructor, which creates an empty stack. Stack includes all the methods defined by
Vector, and adds several of its own.
StringTokenizer − This class allows an application to break a string into tokens. This class is a legacy
class that is retained for compatibility reasons although its use is discouraged in new code.
Timer − This class provides facility for threads to schedule tasks for future execution in a background
thread.
TimerTask − This class represents a task that can be scheduled for one-time or repeated execution by a
Timer.
TimeZone − This class represents a time zone offset, and also figures out daylight savings.
TreeMap − This class is the Red-Black tree based implementation of the Map interface. The TreeMap
class guarantees that the Map will be in ascending key order.
TreeSet − This class implements the Set interface. The TreeSet class guarantees that the Set will be in
ascending key order and backed by a TreeSet.
UUID − This class class represents an immutable universally unique identifier (UUID). There are four
different basic types of UUIDs: time-based, DCE security, name-based, and randomly generated UUIDs.
Vector − Vector implements a dynamic array. The Vector class implements a growable array of objects.
Similar to an Array, it contains components that can be accessed using an integer index.
Examples of [Link] Package
Powered
Practice the following examples to learn the concept and usage by:
of [Link] package clasess.
Example of [Link]
The following program illustrates several of the methods supported
00:00 by ArrayList −
Page 5 of 9
package [Link];
import [Link];
public class ArrayListDemo {
public static void main(String args[]) {
// create an array list
ArrayList al = new ArrayList();
[Link]("Initial size of al: " + [Link]());
// add elements to the array list
[Link]("C");
[Link]("A");
[Link]("E");
[Link]("B");
[Link]("D");
[Link]("F");
[Link](1, "A2");
[Link]("Size of al after additions: " + [Link]());
// display the array list
[Link]("Contents of al: " + al);
// Remove elements from the array list
[Link]("F");
[Link](2);
[Link]("Size of al after deletions: " + [Link]());
[Link]("Contents of al: " + al);
}
}
This will produce the following result −
Output
Powered by:
Initial size of al: 0
Size of al after additions: 7
Contents of al: [C, A2, A, E, B, D, F]
00:00
Page 6 of 9
Size of al after deletions: 5
Contents of al: [C, A2, E, B, D]
Example of [Link]
This Java example demonstrates the from() method of Date class to get Date instance of current time.
package [Link];
import [Link];
// Import the Date package
import [Link];
// Main public class
public class DateDemo {
public static void main(String[] args) {
// create a date of current time
Date date = [Link]([Link]());
// print the date instance
[Link]("Date: " + [Link]());
}
}
Output
Let us compile and run the above program, this will produce the following result −
Date: Mon Apr 01 10:20:08 IST 2024
Example of [Link]
The following example shows the usage of Java Random doubles() method. Firstly, we've created a Random
Powered by:
object and then using doubles() we retrieved a stream of random double values and printed first value.
00:00
Page 7 of 9
package [Link];
import [Link];
import [Link];
public class RandomDemo {
public static void main( String args[] ) {
// create random object
DoubleStream randomNoStream = new Random().doubles();
// print a random double value
[Link](1).forEach( i -> [Link](i));
}
}
Output
Let us compile and run the above program, this will produce the following result.
0.5129590222446587
When [Link] Package is Used?
Whenever we need to manipulate collections, Strings, perform event handling etc, we can rely on utility classes
present in [Link] package. This reference has been prepared for the beginners to help them understand the
Powered
basic functionality related to all the methods available in [Link] by:
package.
Prerequisites
00:00
Page 8 of 9
Before you start doing practice with various types of examples given in this reference, I'm making an assumption
that you are already aware of basic Java Programming.
TOP TUTORIALS TRENDING TECHNOLOGIES
Python Tutorial Cloud Computing Tutorial
Java Tutorial Amazon Web Services Tutorial
C++ Tutorial Microsoft Azure Tutorial
C Programming Tutorial Git Tutorial
C# Tutorial Ethical Hacking Tutorial
PHP Tutorial Docker Tutorial
R Tutorial Kubernetes Tutorial
HTML Tutorial DSA Tutorial
CSS Tutorial Spring Boot Tutorial
JavaScript Tutorial SDLC Tutorial
SQL Tutorial Unix Tutorial
CERTIFICATIONS COMPILERS & EDITORS
Business Analytics Certification Online Java Compiler
Java & Spring Boot Advanced Certification Online Python Compiler
Data Science Advanced Certification Online Go Compiler
Cloud Computing And DevOps Online C Compiler
Advanced Certification In Business Analytics Online C++ Compiler
Artificial Intelligence And Machine Learning Online C# Compiler
DevOps Certification Online PHP Compiler
Game Development Certification Online MATLAB Compiler
Front-End Developer Certification Online Bash Terminal
AWS Certification Training Online SQL Compiler
Python Programming Certification Online Html Editor
ABOUT US | OUR TEAM | CAREERS | JOBS | CONTACT US | TERMS OF USE | PRIVACY POLICY |
REFUND POLICY | COOKIES POLICY | FAQ'S
Powered by:
00:00
Page 9 of 9
Tutorials Point is a leading Ed Tech company striving to provide the best learning material on technical and non-
technical subjects.
© Copyright 2025. All Rights Reserved.
Powered by:
00:00