像数组一样,我们还可以使用循环在JavaTuples中遍历Septet类。
首先让我们看看使用JavaTuples所需的工具。要在JavaTuples中使用Septet类,您需要导入以下包-
import org.javatuples.Septet;
注-下载和运行JavaTuples程序的步骤如果您正在使用Eclipse IDE在JavaTuples中运行Septet类,则右键单击Project→Properties→Java Build Path→Add External Jars并上传下载的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("Jack", "Sam", "Tom", "Kate", "David", "Kevin", "Angelina");
for (Object ob: s)
System.out.println(ob);
}
}输出结果
Jack Sam Tom Kate David Kevin Angelina