用Java创建Septet元组
要使用Java创建Septet元组,请使用with()
方法。
首先让我们看看使用JavaTuples所需的工具。要在JavaTuples中使用Septet类,您需要导入以下包-
import org.javatuples.Septet;
注-下载和运行JavaTuples程序的步骤。如果您正在使用EclipseIDE在JavaTuples中运行Septet类,请右键单击Project->Properties->JavaBuildPath->AddExternalJars并上传下载的JavaTuplesjar文件。
以下是一个例子-
示例
import org.javatuples.Septet; public class Demo { public static void main(String[] args) { Septet < String, String, String, String, String, String, String > s = Septet.with("Mobile", "Tablet", "TV", "Laptop", "Desktop", "Tablet", "Smart TV"); System.out.println(s); } }
输出结果
[Mobile, Tablet, TV, Laptop, Desktop, Tablet, Smart TV]