Author: saqibkhan

  • 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 − Learn Java in-depth with real-world projects through our Java certification course. Enroll and become a certified expert to boost your career. Class Constructor Sr.No. Constructor & Description 1 Quintet(A value0, B value1, C value2, D value3, E value4)This creates a Quintet Tuple.…

  • Quartet Class

    Introduction The org.javatuples.Quartet class represents a Tuple with four elements. Class Declaration Following is the declaration for org.javatuples.Quartet class − Learn Java in-depth with real-world projects through our Java certification course. Enroll and become a certified expert to boost your career. Class Constructor Sr.No. Constructor & Description 1 Quartet(A value0, B value1, C value2, D value3)This creates a Quartet Tuple. Class Methods…

  • Triplet Class

    Introduction The org.javatuples.Triplet class represents a Tuple with three elements. Class Declaration Following is the declaration for org.javatuples.Triplet class − Learn Java in-depth with real-world projects through our Java certification course. Enroll and become a certified expert to boost your career. Class Constructors Sr.No. Constructor & Description 1 Triplet(A value0, B value1, C value2)This creates a Triplet Tuple. Class Methods Similarly setAt1()…

  • Pair Class

    Introduction The org.javatuples.Pair class represents a Tuple with two elements. Class Declaration Following is the declaration for org.javatuples.Pair class − Learn Java in-depth with real-world projects through our Java certification course. Enroll and become a certified expert to boost your career. Class Constructor Sr.No. Constructor & Description 1 Pair(A value0, B value1)This creates a Pair Tuple. Class Methods Similarly setAt1() set the…

  • Unit Class

    Introduction The org.javatuples.Unit class represents a Tuple with single element. Class declaration Following is the declaration for org.javatuples.Unit class − Learn Java in-depth with real-world projects through our Java certification course. Enroll and become a certified expert to boost your career. Class constructors Sr.No. Constructor & Description 1 Unit(A value0)This creates a Unit Tuple. Class Methods Sr.No. Method & Description 1 Pair…

  • Checking Elements

    Each tuple provides utility methods to check their elements in similar fashion as collection. Example Let’s see JavaTuples in action. Here we’ll see how to check elements in a tuple. Create a java class file named TupleTester in C:\>JavaTuples. File: TupleTester.java Verify the result Compile the classes using javac compiler as follows − Now run the TupleTester to…

  • Iteration

    Each tuple implements Iterable interface and can be iterated in similar fashion as collection. Example Let’s see JavaTuples in action. Here we’ll see how to iterate tuples. Create a java class file named TupleTester in C:\>JavaTuples. File: TupleTester.java Verify the result Compile the classes using javac compiler as follows − Now run the TupleTester to see the result…

  • Conversion

    Tuple to List/Array A tuple can be converted to List/Array but at cost of type safety and converted list is of type List<Object>/Object[]. Collection/Array to Tuple A collection can be converted to tuple using fromCollection() method and array can be converted to tuple using fromArray() method. If size of array/collection is different than that of…

  • Remove Elements

    A tuple has removeAtX() methods to remove value at particular index. For example Triplet class has following methods. Removing an element returns a new tuple. Example Let’s see JavaTuples in action. Here we’ll see how to remove value in a tuple. Create a java class file named TupleTester in C:\>JavaTuples. File: TupleTester.java Verify the result Compile…

  • Add Elements

    A tuple has add() method at the end of a tuple and it changes the type of tuple as well. For example adding a element to Triplet tuple will convert it to a Quartet tuple. A tuple has addAtX() methods as well to add a position at particular index starting from 0. A tuple can…