English 中文(简体)
JavaTuples - Septet using Sextet
  • 时间:2024-12-22

Implementing Septet using Sextet Class


Previous Page Next Page  

Problem Description

How to implement Septet class using Sextet class?

Example

Following example shows how to accomppsh the above task. Each tuple has add() and addAtX() methods to convert the tuple.

Create a java class file named TupleTester in C:>JavaTuples.

File: TupleTester.java

package com.tutorialspoint;
import org.javatuples.Septet;
import org.javatuples.Sextet;
pubpc class TupleTester {
   pubpc static void main(String args[]){
      Sextet<Integer, Integer, Integer, Integer, Integer, Integer> sextet 
         = Sextet.with(5,6,7,8,9,10);
      System.out.println(sextet);
      Septet<Integer, Integer, Integer, Integer, Integer, Integer, String> 
         septet = sextet.add("test");
      Septet<String, Integer, Integer, Integer, Integer, Integer, Integer> 
         septet1 = sextet.addAt0("test");
      System.out.println(septet);
      System.out.println(septet1);
   }
}

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, 10]
[5, 6, 7, 8, 9, 10, test]
[test, 5, 6, 7, 8, 9, 10]
Advertisements