- JavaTuples - Discussion
- JavaTuples - Useful Resources
- JavaTuples - Quick Guide
- JavaTuples - Decade using Ennead
- JavaTuples - Ennead using Octet
- JavaTuples - Octet using Septet
- JavaTuples - Septet using Sextet
- JavaTuples - Sextet using Quintet
- JavaTuples - Quintet using Quartet
- JavaTuples - Quartet using Triplet
- JavaTuples - Triplet using Pair
- JavaTuples - Pair using Unit
- JavaTuples - KeyValue Class
- JavaTuples - LabelValues Class
- JavaTuples - Decade Class
- JavaTuples - Ennead Class
- JavaTuples - Octet Class
- JavaTuples - Septet Class
- JavaTuples - Sextet Class
- JavaTuples - Quintet Class
- JavaTuples - Quartet Class
- JavaTuples - Triplet Class
- JavaTuples - Pair Class
- JavaTuples - Unit Class
- JavaTuples - Checking Elements
- JavaTuples - Iteration
- JavaTuples - Conversion
- JavaTuples - Remove Elements
- JavaTuples - Add Elements
- JavaTuples - Set Values
- JavaTuples - Get Values
- JavaTuples - Create Tuples
- JavaTuples - Environment Setup
- JavaTuples - Overview
- JavaTuples - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
JavaTuples - Overview
Tuple
Tuple is a sequence of objects which may or may not be of same type. Consider the following example −
[12,"TutorialsPoint", java.sql.Connection@p757b]
Above object is a tuple of three elements, an Integer, a string and a Connection Object.
JavaTuple
JavaTuples is a very simple pbrary which offers ten different tuple classses which are sufficient to handle most of the tuple related requirements.
Unit<A> - 1 element
Pair<A,B> - 2 elements
Triplet<A,B,C> - 3 elements
Quartet<A,B,C,D> - 4 elements
Quintet<A,B,C,D,E> - 5 elements
Sextet<A,B,C,D,E,F> - 6 elements
Septet<A,B,C,D,E,F,G> - 7 elements
Octet<A,B,C,D,E,F,G,H> - 8 elements
Ennead<A,B,C,D,E,F,G,H,I> - 9 elements
Decade<A,B,C,D,E,F,G,H,I,J> - 10 elements
Apart from these tuple classes, JavaTuples also provides two additional classes for semantics sake.
KeyValue<A,B>
LabelValue<A,B>
All tuple classes are typesafe and immutable and implements following interfaces and methods.
Iterable
Seriapzable
Comparable<Tuple>
equals()
hashCode()
toString()
Tuple vs List/Array
List or Array can contain any number of elements but each element must be of same type whereas tuples can contain only specific number of elements, can have different type of elements but still are typesafe.
Advertisements