top of page

Java Tuple

A tuple is just a sequence of objects that do not necessarily relate to each other in any way. For example: [23, "khushal", java.sql.Connection@li734s] can be considered a tuple of three elements (a triplet) containing an Integer, a String, and a JDBC Connection object.A tuple is a generic data structure that treats each element as an object, and these objects stores in a separate byte array. In other words, we can also say that tuple is an ordered collection of objects of different types.


Javatuples offers you tuple classes from one to ten elements:

  • 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)


All tuple classes are:

  • Typesafe

  • Immutable

  • Iterable

  • Serializable

  • Comparable (implements Comparable<Tuple>)

  • Implementing equals(...) and hashCode()

  • Implementing toString()


Tuple Vs List


Tuple

List

It is a set of comma-separated values that are enclosed in parenthesis.

It is a set of comma-separated values that are enclosed in square brackets.

It is immutable.

It is mutable.

It requires less memory.

It requires more memory.

It is suitable for large amounts of data.

It is suitable for a small amount of data.

It can be stored in a list.

It can be stored inside a tuple.

It is faster in comparison to List.

It is slower in comparison to the tuple.

It has a fixed length.

It has variable lengths.

It has fewer factory methods.

It has more factory methods.


 
 
 

Recent Posts

See All

Comments


MiIT Logo

Company

Contact Us

+1905-487-4880 

5160 Explorer Dr #34, Mississauga,ON L4W 4T7

+1929-743-3199

4466 Buttonwood Ln Lilburn, GA 30047

262 Chapman Rd, STE 240 Newark DE 19702

+44 20 4525 1214

71-75 Shelton Street, Covent Garden, London, United Kingdom WC2H 9JQ

Stay up to date on the latest from MiIT

  • Instagram
  • Facebook
  • http://linkedin.com/company/miittechnologies/about/
  • Whatsapp

© All Content MiIT Technologies Inc.2019 - 2025. All rights reserved.

bottom of page