- 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 - Quintet Class
Introduction
The org.javatuples.Quintet class represents a Tuple with five elements.
Class Declaration
Following is the declaration for org.javatuples.Quintet class −
pubpc final class Quintet<A, B, C, D, E> extends Tuple implements IValue0<A>, IValue1<B>, IValue2<C>, IValue3<D>, IValue4<E>
Class Constructor
Sr.No. | Constructor & Description |
---|---|
1 | Quintet(A value0, B value1, C value2, D value3, E value4) This creates a Quintet Tuple. |
Class Methods
Sr.No. | Method & Description |
---|---|
1 | Sextet add(Unit tuple) This method returns a Sextet tuple. Similarly other methods to add tuples are available e.g. add(Pair tuple) returns Septet and upto add(Quintet tuple) returns Decade tuple. |
2 | Sextet add(X0 value) This method add a value to the tuple and returns a Sextet tuple. Similarly other methods to add values are available e.g. add(X0 value0, X1 value1) returns Septet and so on upto add() with five parameters. |
3 | Sextet addAt0(Unit value) This method add a Unit tuple at index 0 and returns a Sextet tuple. Similarly other methods to add tuples are available e.g. addAt0(Pair value) returns Septet and so on upto addAt0(Quintet). Other similar method are addAt1(Unit value) which add a unit at index0 and have similar methods upto addAt4(Quintet). |
4 | Sextet addAt0(X0 value) This method add a value at index 0 and returns a Sextet tuple. Similarly other methods to add values are available e.g. addAt0(X0 value0, X1 value1) returns Septet and so on upto addAt0() with five parameters. Other similar method are addAt1(X0 value) which add a value at index0 and have similar methods upto addAt4() with five parameters. |
5 | static <X> Quintet<X,X,X,X,X> fromArray(X[] array) Create tuple from array. |
6 | static <X> Quintet<X,X,X,X,X> fromCollection(Collection<X> collection) Create tuple from collection. |
7 | static <X> Quintet<X,X,X,X,X> fromIterable(Iterable<X> iterable) Create tuple from iterable. |
8 | static <X> Quintet<X,X,X,X,X> fromIterable(Iterable<X> iterable, int index) Create tuple from iterable, starting from the specified index. |
9 | int getSize() Return the size of the tuple. |
10 | A getValue0() Returns the value of the tuple at index 0. Similarly getValue1() upto getValue4() returns the value at index 1 and so on. |
11 | Quartet<B,C,D,E> removeFrom0() Return the tuple after removing value of the tuple at index 0. Similarly removeFrom1() upto removeFrom4() returns the tuple after removing value of the tuple at index 1 and so on. |
12 | <X> Quintet<X,B,C,D,E> setAt0(X value) Set the value of the tuple at index 0. |
13 | static <A> Quintet<A,B,C,D,E> with(A value0, B value1, C value2, D value3, E value4) Create the tuple using given value. |
Methods inherite
This class inherits methods from the following classes −
org.javatuples.Tuple
Object
Example
Let s see Quintet Class in action. Here we ll see how to use various methods.
Create a java class file named TupleTester in C:>JavaTuples.
File: TupleTester.java
package com.tutorialspoint; import java.util.ArrayList; import java.util.List; import org.javatuples.Quartet; import org.javatuples.Quintet; import org.javatuples.Sextet; import org.javatuples.Triplet; pubpc class TupleTester { pubpc static void main(String args[]){ Quintet<Integer, Integer, Integer, Integer, Integer> quintet = Quintet.with(5, 6, 7,8,9); System.out.println(quintet); boolean isPresent = quintet.contains(5); System.out.println("5 is present: " + isPresent); List<Integer> pst = new ArrayList<>(); pst.add(1); pst.add(2); pst.add(3); pst.add(4); pst.add(5); Sextet<Integer, Integer, Integer, Integer, Integer, String> sextet = quintet.add("Test"); System.out.println(sextet); Integer value = quintet.getValue0(); System.out.println(value); Quartet<Integer, Integer, Integer, Integer> quartet = quintet.removeFrom0(); System.out.println(quartet); Quintet<Integer, Integer, Integer, Integer, Integer> quintet1 = Quintet.fromCollection(pst); System.out.println(quintet1); } }
Verify the result
Compile the classes using javac compiler as follows −
C:JavaTuples>javac -cp javatuples-1.2.jar ./com/tutorialspoint/TupleTester.java
Now run the TupleTester to see the result −
C:JavaTuples>java -cp .;javatuples-1.2.jar com.tutorialspoint.TupleTester
Output
Verify the Output
[5, 6, 7, 8, 9] 5 is present: true [5, 6, 7, 8, 9, Test] 5 [6, 7, 8, 9] [1, 2, 3, 4, 5]Advertisements