从 Java 中的 Decade Tuple 中获取值
要从 Java 中的 Decade Tuple 中获取值,请使用 getAtX() 方法。其中 X 表示索引值(例如索引 1 处的 getAt1())。这将返回元组中索引 1 处元素。
首先,让我们来看看使用 JavaTuples 所需的内容。要使用 JavaTuples 中的 Decade 类,你需要导入以下包
import org.javatuples.Decade;
注意下载 JavaTuples Jar 库来运行 JavaTuples 程序。如果你正在使用 Eclipse IDE,则右键单击项目 -> 属性 -> Java 构建路径 -> 添加外部 JAR,并上传已下载的 JavaTuples jar 文件。有关运行 JavaTuples 的所有步骤,请参阅以下指南
步骤:如何在 Eclipse 中运行 JavaTuples 程序
以下是从 Java 中的 Decade Tuple 中获取值的示例
示例
import org.javatuples.Decade;
public class Demo {
public static void main(String[] args) {
String[] strArr = {"AB", "CD", "EF","GH", "IJ", "KL","MN", "OP", "QR","ST" };
Decade<String, String, String, String, String, String, String, String, String, String> d = Decade.fromArray(strArr);
System.out.println("Elements in the Decade Tuple = ");
System.out.println("Element at index 1 = "+d.getValue1());
System.out.println("Element at index 4 = "+d.getValue4());
System.out.println("Element at index 7 = "+d.getValue7());
System.out.println("Element at index 9 = "+d.getValue9());
}
}输出
Elements in the Decade Tuple = Element at index 1 = CD Element at index 4 = IJ Element at index 7 = OP Element at index 9 = ST
广告
数据结构
网络
关系型数据库管理系统 (RDBMS)
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP