The class AbstractMap.SimpleEntry is generic and can be useful.

Answer from Eyal Schneider on Stack Overflow
🌐
Baeldung
baeldung.com › home › java › core java › using pairs in java
Using Pairs in Java | Baeldung
March 13, 2024 - In summary, Pair is best suited for handling a single key-value association or when returning two related values from a method. HashMap, however, is more appropriate for cases that involve storing multiple key-value pairs and require efficient data retrieval and modification capabilities. We can find the Pair class in the javafx.util package.
🌐
How to do in Java
howtodoinjava.com › home › pairs in java
Java Pair class - key value pair data structure in Java - HowToDoInJava
October 1, 2022 - Learn to work with key value pairs in Java using Pair classes e.g. javafx.util.Pair, ImmutablePair, MmutablePair (common langs) and io.vavr.Tuple2 class. Read More : Tuples in Java 1. Why we need pairs? A pair provide a convenient way of associating a simple key to value.
🌐
Delft Stack
delftstack.com › home › howto › java › java key value pair
How to Implement Key Value Pair in Java | Delft Stack
February 12, 2024 - The Properties method provides a concise and effective way to implement key-value pairs in Java, particularly for configuration settings. Its simplicity makes it an excellent choice for scenarios where you need to store and retrieve key-value pairs without the complexity of other data structures. It is often used for reading and writing configuration files, making it a versatile tool for storing and retrieving key-value pairs. By using the Properties class, you gain a versatile tool for managing configuration settings and other key-value data in your Java applications.
🌐
CodeGym
codegym.cc › java blog › java objects › pairs in java
Pairs in Java
December 18, 2024 - Although it is not a built-in class ... way to manage key/value pairs. The Pair class has two fields: key and value, representing the key and value associated with the pair, respectively....
🌐
GeeksforGeeks
geeksforgeeks.org › java › pair-class-in-java
Pair Class in Java - GeeksforGeeks
July 23, 2025 - We were looking for an equivalent class for pair in Java but Pair class did not come into existence till Java 7. JavaFX 2.2 has the javafx.util.Pair class which can be used to store a pair.
🌐
Oracle
docs.oracle.com › middleware › 12212 › wcs › java-ref › com › fatwire › rest › beans › KeyValuePair.html
KeyValuePair (Oracle WebCenter Sites Java API Reference)
Java class for keyValuePair complex type. The following schema fragment specifies the expected content contained within this class. <complexType name="keyValuePair"> <complexContent> <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> <sequence> <element name="key" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> <element name="value" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> </sequence> </restriction> </complexContent> </complexType> clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait ·
🌐
W3Docs
w3docs.com › java
A KeyValuePair in Java
public class KeyValuePair<K, V> ... key = pair.getKey(); int value = pair.getValue(); ... Note that Java does not have a built-in KeyValuePair class, so you will need to define your own or use a third-party libra...
Find elsewhere
🌐
Apache Kafka
kafka.apache.org › 26 › javadoc › org › apache › kafka › streams › KeyValue.html
KeyValue (kafka 2.6.0 API)
java.lang.Object · org.apache.kafka.streams.KeyValue<K,V> Type Parameters: K - Key type · V - Value type · public class KeyValue<K,V> extends Object · A key-value pair defined for a single Kafka Streams record. If the record comes directly from a Kafka topic then its key/value are defined ...
🌐
BeginnersBook
beginnersbook.com › 2013 › 12 › hashmap-in-java-with-example
HashMap in Java With Examples
September 19, 2022 - HashMap is a Map based collection class that is used for storing Key & value pairs, it is denoted as HashMap<Key, Value> or HashMap<K, V>. HashMap in java, is similar to the Hashtable class except that it is unsynchronized and permits nulls(null values and null key).
🌐
AWS
docs.aws.amazon.com › AWSJavaSDK › latest › javadoc › com › amazonaws › services › ecs › model › KeyValuePair.html
KeyValuePair (AWS SDK for Java - 1.12.797)
@Generated(value="com.amazonaws:aws-java-sdk-code-generator") public class KeyValuePair extends Object implements Serializable, Cloneable, StructuredPojo · A key-value pair object.
🌐
Dev.java
dev.java › learn › api › collections-framework › maps
Using Maps to Store Key Value Pairs - Dev.java
September 14, 2021 - Indeed, a SortedMap shares the same kind of semantics as the SortedSet: a SortedMap is a map that keeps its key-value pairs sorted by their keys. The same goes for NavigableMap: the methods added by this interface are the same kind of methods than the ones added by NavigableSet to SortedSet. The JDK gives you several implementations of the Map interface, the most widely used is the HashMap class.
🌐
Princeton CS
introcs.cs.princeton.edu › java › code › javadoc › ST.html
Class ST<Key extends Comparable<Key>,​Value>
The ST class represents an ordered symbol table of generic key-value pairs. It supports the usual put, get, contains, remove, size, and is-empty methods. It also provides ordered methods for finding the minimum, maximum, floor, and ceiling. It also provides a keys method for iterating over ...
🌐
W3Schools
w3schools.com › java › java_hashmap.asp
Java HashMap
A HashMap stores items in key/value pairs, where each key maps to a specific value. It is part of the java.util package and implements the Map interface. Instead of accessing elements by an index (like with ArrayList), you use a key to retrieve ...
🌐
Microsoft Learn
learn.microsoft.com › en-us › java › api › com.azure.resourcemanager.chaos.models.keyvaluepair
KeyValuePair Class | Microsoft Learn
Creates an instance of KeyValuePair class. public static KeyValuePair fromJson(JsonReader jsonReader) Reads an instance of KeyValuePair from the JsonReader. ... An instance of KeyValuePair if the JsonReader was pointing to an instance of it, or null if it was pointing to JSON null. ... IOException - If the deserialized JSON object was missing any required properties. ... Get the key property: The name of the setting for the action. ... Validates the instance. ... Get the value property: The value of the setting for the action.
🌐
Oracle
docs.oracle.com › middleware › 1213 › oer › OEREF › com › flashline › registry › openapi › entity › KeyValuePair.html
KeyValuePair (Oracle&copy; Fusion Middleware Extensibility Framework (REX) for Oracle Enterprise Repository)
public class KeyValuePair extends java.lang.Object implements java.io.Serializable · See Also: Serialized Form · clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait · public KeyValuePair() public KeyValuePair(java.lang.String key, java.lang.String value) public java.lang.String getKey() Gets the key value for this KeyValuePair.
🌐
Technogeeks CS
technogeekscs.com › home › blog › programming › pair in java
Pair Class in Java: A Powerful Data Structure | Technogeeks
March 5, 2026 - The Pair class is immutable, meaning that once created, its values cannot be modified. In the above code snippet, the Pair class is implemented with two private instance variables: key and value, representing the pair's components.