setAt0()方法用于在JavaTuples中设置Quintet值,并在指定的索引(即此处的索引0)处设置具有新值的副本。
首先让我们看看使用JavaTuples所需的工具。要在JavaTuples中使用Quintet类,您需要导入以下包-
import org.javatuples.Quintet;
注-下载和运行JavaTuples程序的步骤如果您正在使用Eclipse IDE在JavaTuples中运行Quintet类,则右键单击Project→Properties→Java Build Path→Add External Jars并上传下载的JavaTuples jar文件。
以下是一个例子-
import org.javatuples.Quintet; public class Demo { public static void main(String[] args) { Quintet < String, String, String, String, String > q1 = Quintet.with("TV", "Laptop", "Desktop", "Tablet", "Smart TV"); Quintet < String, String, String, String, String > q2 = q1.setAt0("E-Book Reader"); System.out.println("Result = " + q2); } }
输出结果
Result = [E-Book Reader, Laptop, Desktop, Tablet, Smart TV]