Pair类的Java Tuple setAt1()方法
setAt0()方法用于在JavaTuples中设置Pair值,并在指定的索引(即此处的索引1)处设置具有新值的副本。
首先让我们看看使用JavaTuples所需的工具。要在JavaTuples中使用Pair类,您需要导入以下包-
import org.javatuples.Pair;
注-下载和运行JavaTuples程序的步骤如果您正在使用EclipseIDE在JavaTuples中运行PairClass,请右键单击Project→Properties→JavaBuildPath→AddExternalJars并上传下载的JavaTuplesjar文件。
以下是一个例子-
示例
import org.javatuples.Pair;
public class Demo {
public static void main(String[] args) {
Pair < String, String > p1 = Pair.with("One", "Two");
Pair < String, String > p2 = p1.setAt1("Three");
System.out.println("Result = " + p2);
}
}输出结果
Result = [One, Three]
热门推荐
10 仙女减肥成功祝福语简短
11 小亲戚生日祝福语简短
12 美好超市员工祝福语简短
13 元诞祝福语简短2026
14 考试专属祝福语大全简短
15 客户入住新房祝福语简短
16 男娃过生日简短祝福语
17 生日祝福语简短笑话短句
18 升职英文简短祝福语大全