Util package program in java

java util Package — java.util Package in Java

The java.util package provides Java collections framework classes, internationalization support classes, a service loader, properties, random number generation, string parsing and scanning classes, base64 encoding and decoding, a bit array, and several miscellaneous utility classes. This package also contains legacy collection classes and legacy date and time classes.

Package java.util

Package java.util contains the collections framework, legacy collection classes, event model, date and time facilities, internationalization, and miscellaneous utility classes (a string tokenizer, a random-number generator, and a bit array).

What is java.util Package ?

The java.util package is a Java package like other packages in Java. Like java.lang package, Java util package also a package which contains Java collections framework classes. Assuming you mean the packages that include the class libraries like java.lang.* and java.util.*, these live in the «lib» directory under wherever your Java Runtime Environment (JRE) is installed.

What is import java.util.* in Java ?

The import is a java keyword which is used for importing a Java class or entire Java package. For example import java.util.Calendar; means you are importing a single Calendar class. If you want to import all the classes from any Java package, your import statement must be like this import java.util.* that means you are importing entire java.util package.

Читайте также:  Css make footer at bottom

java.util Package Import Statement Example

What does import java.util.* do in Java ?

Java util ( java.util.* ) package contains collection framework . Java collections framework contains collection classes , classes related to date and time , event model , internationalization , and miscellaneous utility classes . On importing this ( java.util ) package , you can do access all these classes and methods .

What is the use of java.util Package in Java ?

The use of java.util package is as follows

  1. It can be use for Java collections.
  2. It can be use for internationalization support by using the internationalization supported classes from java.util package.
  3. It can be use for random number generation.
  4. It can be use for string parsing.
  5. It can be use for base64 encoding and decoding.

java util Package - java.util Package in Java, java.util package provides Java collections framework, internationalization, service loader, properties, random number generation, string parsing and scanning., Complete Tutorial on java.util Package.

What is Collections Framework in Java ?

A collection sometimes called a container is simply an object that groups multiple elements into a single unit. Collections are used to store, retrieve, manipulate, and communicate aggregate data in Java .

  • A collection is the same as the intuitive, mathematical concept of a set. A set is just a group of unique items, meaning that the group contains no duplicates.
  • Java Collections Framework provides a set of interfaces and classes for storing and manipulating groups of data as a single unit, a collection.
  • The framework provides a convenient API to many of the abstract data types maps, sets, lists, trees, arrays, hashtables, and other collections.
  • Because of their object-oriented design, the Java classes in the Collections Framework encapsulate both the data structures and the algorithms associated with these abstractions.
  • With the Java Collections Framework the programmer easily define higher level data abstractions, such as stacks, queues, and thread safe collections.

java.util package contains Java Collections Framework classes as follows.

Java Collections Framework Classes

AbstractCollection

The AbstractCollection class provides a skeletal implementation of the Collection interface, to minimize the effort required to implement this interface.

Читайте также:  Генерация синтетических данных python

AbstractList

The AbstractList class provides a skeletal implementation of the List interface to minimize the effort required to implement this interface backed by a «random access» data store (such as an array).

AbstractMap

The AbstractMap class provides a skeletal implementation of the Map interface, to minimize the effort required to implement this interface.

AbstractQueue

The AbstractQueue class provides skeletal implementations of some Queue operations.

AbstractSequentialList

The AbstractSequentialList class provides a skeletal implementation of the List interface to minimize the effort required to implement this interface backed by a «sequential access» data store (such as a linked list).

AbstractSet

The AbstractSet class provides a skeletal implementation of the Set interface to minimize the effort required to implement this interface..

ArrayDeque

The ArrayDeque class Resizable-array implementation of the Deque interface.

ArrayList

The ArrayList class Resizable-array implementation of the List interface.

Arrays

The Arrays class contains various methods for manipulating arrays (such as sorting and searching).

Collections

The Collections class consists exclusively of static methods that operate on or return collections.

EnumMap

The EnumMap class A specialized Map implementation for use with enum type keys.

EnumSet

The EnumSet class A specialized Set implementation for use with enum types.

HashMap

The HashMap class Hash table based implementation of the Map interface.

HashSet

The HashSet class implements the Set interface, backed by a hash table (actually a HashMap instance).

HashTable

The HashTable class implements a hash table, which maps keys to values.

IdentityHashMap

The IdentityHashMap class implements the Map interface with a hash table, using reference-equality in place of object-equality when comparing keys (and values).

LinkedHashMap

The LinkedHashMap class Hash table and linked list implementation of the Map interface, with predictable iteration order.

Читайте также:  Java arraylist example with objects

LinkedHashSet

The LinkedHashSet class Hash table and linked list implementation of the Set interface, with predictable iteration order.

LinkedList

The LinkedList class Doubly-linked list implementation of the List and Deque interfaces.

PriorityQueue

The PriorityQueue class An unbounded priority queue based on a priority heap.

TreeMap

The TreeMap class A Red-Black tree based NavigableMap implementation.

TreeSet

The TreeSet class A NavigableSet implementation based on a TreeMap.

Vector

The Vector class implements a growable array of objects.

WeakHashMap

The WeakHashMap class Hash table based implementation of the Map interface, with weak keys.

Internationalization I18N Supported Classes in Java

Create application that can be adapted to different languages and regions is known as Internationalization I18N. Which provides support for various countries, various languages and various currency formates without performing any change in the application.

Internationalization is also abbreviated as I18N because there are total 18 characters between the first letter ‘I’ and the last letter ‘N’.

Internationalization I18N Supported Classes in Java as follows.

  1. Locale : A Java Locale class represents a specific geographical, political, or cultural region.
  2. Locale.Builder : Builder is used to build instances of Locale from values configured by the setters.
  3. ResourceBundle : Resource bundles contain locale-specific objects.

ServiceLoader Class in Java

A facility to load implementations of a service. A service is a well-known interface or class for which zero, one, or many service providers exist. A service provider (or just provider) is a class that implements or subclasses the well-known interface or class.

Properties Class in Java

The Properties class represents a persistent set of properties. The Properties can be saved to a stream or loaded from a stream. Each key and its corresponding value in the property list is a string.

Java JDBC Tutorial - Java Database Connectivity Java byte Array what is coronavirus covid-19 Python Data Types Java Basics HTML5 Tags Tutorial Java double Array How to store byte array in MySQL using Java The Python Tutorial 9 Best Father’s Day 2023 Gifts Java Collections Framework Python Keywords Happy Father Java Arrays HTML5 Tutorial How to store byte array in SQL Server using Java Father

© 2010 — 2023 HudaTutorials.com All Rights Reserved.

Источник

Оцените статью