English 中文(简体)
JavaTuples - Decade using Ennead
  • 时间:2024-11-03

Implementing Decade Using Ennead Class


Previous Page Next Page  

Problem Description

How to implement Decade class using Ennead 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.Decade;
import org.javatuples.Ennead;
pubpc class TupleTester {
   pubpc static void main(String args[]){
      Ennead<Integer, Integer, Integer, Integer, Integer, Integer,
         Integer, Integer, Integer> ennead = Ennead.with(5,6,7,8,9,10,11,12,13);
      System.out.println(ennead);
      Decade<Integer, Integer, Integer, Integer, Integer, Integer, 
         Integer, Integer, Integer, String> decade = ennead.add("test");
      
      Decade<String, Integer, Integer, Integer, Integer, Integer, 
         Integer, Integer, Integer, Integer> decade1 = ennead.addAt0("test");
      
      System.out.println(decade);
      System.out.println(decade1);
   }
}

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