Package jline.util
Class Pair
-
- All Implemented Interfaces:
-
java.io.Serializable
,java.lang.Comparable
public class Pair<T, U> implements Comparable<T>, Serializable
A generic pair container that holds two objects of potentially different types.
This utility class provides a simple way to group two related values together. It implements Comparable for ordering pairs and Serializable for persistence. The comparison is based on the left element if it's comparable, otherwise on the right element.
Common use cases:
- Returning multiple values from methods
- Storing coordinate pairs or ranges
- Key-value associations where Map is not suitable
- Temporary grouping of related objects
- Since:
1.0