Javatuples 简明教程
Implementing Decade Using Ennead Class
Example
以下示例描述了如何完成以上任务。每个元组都有 add() 和 addAtX() 方法来转换元组。
Following example shows how to accomplish the above task. Each tuple has add() and addAtX() methods to convert the tuple.
在 C:>JavaTuples 中创建一个名为 TupleTester 的 Java 类文件。
Create a java class file named TupleTester in C:\>JavaTuples.
文件:TupleTester.java
File: TupleTester.java
package com.tutorialspoint;
import org.javatuples.Decade;
import org.javatuples.Ennead;
public class TupleTester {
public 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
Verify the result
使用以下 javac 编译器编译类:
Compile the classes using javac compiler as follows −
C:\JavaTuples>javac -cp javatuples-1.2.jar ./com/tutorialspoint/TupleTester.java
现在运行 TupleTester 查看结果:
Now run the TupleTester to see the result −
C:\JavaTuples>java -cp .;javatuples-1.2.jar com.tutorialspoint.TupleTester