在Java Pair Tuple中搜索值
使用该contains()方法在JavaTuplesPair类中搜索值。
首先让我们看看使用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("Mobile", "Desktop");
System.out.println("Pair = " + p);
boolean res = p.contains("Mobile");
System.out.println("Is the value in Tuple? = " + res);
}
}输出结果
Pair = [Mobile, Desktop] Is the value in Tuple? = true
热门推荐
10 新年门口花束祝福语简短
11 盘锦结婚祝福语大全简短
12 父母生日祝福语 简短独特
13 家庭恩爱祝福语简短英文
14 高考俄语祝福语大全简短
15 虎年祝福语 诗句唯美简短
16 生日婚礼祝福语简短精辟
17 虎年喝酒拜年祝福语简短
18 教师闺蜜祝福语简短