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 50多岁生日简短祝福语
13 安徽疫情祝福语简短英语
14 农民朋友发财祝福语简短
15 对生活祝福语简短精辟
16 搬家词简短祝福语朋友
17 女神结婚快乐祝福语简短
18 文学短句祝福语大全简短