JavaTuples中Pair类的contains()方法
使用contains()方法在配对类中搜索值。
首先让我们看看使用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 > p = Pair.with("Hardware", "Software");
System.out.println("Pair = " + p);
boolean res = p.contains("Firmware");
System.out.println("Is the value in Tuple? = " + res);
}
}输出结果
Pair = [Hardware, Software] Is the value in Tuple? = False
热门推荐
10 小红书平安祝福语简短
11 生日祝福语大全女孩简短
12 收生日红包祝福语 简短
13 领证幽默祝福语简短
14 法考面试祝福语简短
15 老哥出门祝福语简短语
16 送灯祝福语简短独特
17 幼儿狗年祝福语大全简短
18 好听的元旦简短祝福语