
- Java.util - Home
- Java.util - ArrayDeque
- Java.util - ArrayList
- Java.util - Arrays
- Java.util - BitSet
- Java.util - Calendar
- Java.util - Collections
- Java.util - Currency
- Java.util - Date
- Java.util - Dictionary
- Java.util - EnumMap
- Java.util - EnumSet
- Java.util - Formatter
- Java.util - GregorianCalendar
- Java.util - HashMap
- Java.util - HashSet
- Java.util - Hashtable
- Java.util - IdentityHashMap
- Java.util - LinkedHashMap
- Java.util - LinkedHashSet
- Java.util - LinkedList
- Java.util - ListResourceBundle
- Java.util - Locale
- Java.util - Observable
- Java.util - PriorityQueue
- Java.util - Properties
- Java.util - PropertyPermission
- Java.util - PropertyResourceBundle
- Java.util - Random
- Java.util - ResourceBundle
- Java.util - ResourceBundle.Control
- Java.util - Scanner
- Java.util - ServiceLoader
- Java.util - SimpleTimeZone
- Java.util - Stack
- Java.util - StringTokenizer
- Java.util - Timer
- Java.util - TimerTask
- Java.util - TimeZone
- Java.util - TreeMap
- Java.util - TreeSet
- Java.util - UUID
- Java.util - Vector
- Java.util - WeakHashMap
- Java.util - Interfaces
- Java.util - Exceptions
- Java.util - Enumerations
- Java.util Useful Resources
- Java.util - Useful Resources
- Java.util - Discussion
Java Interfaces
Introduction
The Java Interfaces 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).
Interface Summary
Sr.No. | Intreface & Description |
---|---|
1 |
Collection This is the root interface in the collection hierarchy. |
2 |
Comparator This is a comparison function, which imposes a total ordering on some collection of objects. |
3 |
Deque This is a linear collection that supports element insertion and removal at both ends. |
4 |
Enumeration This is an object that implements the Enumeration interface generates a series of elements, one at a time. |
5 |
EventListener This is a tagging interface that all event listener interfaces must extend. |
6 |
Formattable This is the Formattable interface must be implemented by any class that needs to perform custom formatting using the 's' conversion specifier of Formatter. |
7 |
Iterator This is an iterator over a collection. |
8 |
List This is an ordered collection (also known as a sequence). |
9 |
ListIterator This is an iterator for lists that allows the programmer to traverse the list in either direction, modify the list during iteration, and obtain the iterator's current position in the list. |
10 |
Map This is an object that maps keys to values. |
11 |
Map.Entry This is a map entry (key-value pair). |
12 |
NavigableMap This is a SortedMap extended with navigation methods returning the closest matches for given search targets. |
13 |
NavigableSet This is a SortedSet extended with navigation methods reporting closest matches for given search targets. |
14 |
Observer This is a class can implement the Observer interface when it wants to be informed of changes in observable objects. |
15 |
Queue This is a collection designed for holding elements prior to processing. |
16 |
RandomAccess() This is the Marker interface used by List implementations to indicate that they support fast (generally constant time) random access. |
17 |
Set This is a collection that contains no duplicate elements. |
18 |
SortedMap This is a Map that further provides a total ordering on its keys. |
19 |
SortedSet This is a Set that further provides a total ordering on its elements. |
Adding an Element to a HashSet of Integers Example
The following example shows the usage of Java HashSet add() method to add entries to the HashSet. We've created a HashSet object of Integer. Then few entries are added using add() method and then set is printed.
package com.tutorialspoint; import java.util.HashSet; import java.util.Set; public class SetDemo { public static void main(String args[]) { // create hash set SetnewSet = new HashSet <>(); // populate hash set newSet.add(1); newSet.add(2); newSet.add(3); // checking elements in hash set System.out.println("Hash set values: "+ newSet); } }
Output
Let us compile and run the above program, this will produce the following result.
Hash set values: [1, 2, 3]