使用 with() 方法在 Java 中创建 Septet Tuple
java 8object oriented programmingprogramming更新于 2024/11/14 23:34:00
with() 方法用于在 Java 中创建 Septet Tuple。
首先让我们看看使用 JavaTuples 需要什么。要使用 JavaTuples 中的 Septet 类,您需要导入以下包 −
import org.javatuples.Septet;
注意 − 下载和运行 JavaTuples 程序的步骤如果您使用 Eclipse IDE 在 JavaTuples 中运行 Septet 类,则右键单击项目 → 属性 → Java 构建路径 → 添加外部 Jar并上传下载的 JavaTuples jar 文件。
下面是一个例子 −
示例
import org.javatuples.Septet; public class Demo { public static void main(String[] args) { Septet < String, String, String, String, String, String, String > s = Septet.with("One", "Two", "Three", "Four", "Five", "Six", "Seven"); System.out.println(s); } }
输出
[One, Two, Three, Four, Five, Six, Seven]