Java单元元组的contains()方法
要在JavaTuples的Unit类中搜索值,请使用contains()方法。
首先让我们看看使用JavaTuples所需的工具。要使用JavaTuples中的Unit类,您需要导入以下包-
import org.javatuples.Unit;
注-下载和运行JavaTuples程序的步骤如果您正在使用EclipseIDE在JavaTuple中运行单元类,请右键单击Project→Properties→JavaBuildPath→AddExternalJars并上传下载的JavaTuplesjar文件。
以下是一个例子-
示例
import org.javatuples.Unit;
public class Demo {
public static void main(String[] args) {
Unit < String > u = Unit.with("Professional!");
//搜索元素
boolean valSearch = u.contains("Professional!");
System.out.println("Is the value in the Unit? " + valSearch);
}
}输出结果
Is the value in the Unit? True
让我们看另一个例子-
import org.javatuples.Unit;
public class Demo {
public static void main(String[] args) {
Unit < String > u = Unit.with("Mobile!");
//搜索元素
boolean valSearch = u.contains("Desktop!");
System.out.println("Is the value in the Unit? " + valSearch);
}
}输出结果
Is the value in the Unit? False
热门推荐
3 祝福语简短的微信
10 幼儿祝福语大全简短贺卡
11 感谢教官文案祝福语简短
12 鼠年同事祝福语简短创意
13 元旦祝福语 简短独特群发
14 妈咪跟我生日祝福语简短
15 给儿子新婚祝福语简短
16 伴娘祝福语长文案简短
17 恭喜高考完祝福语简短
18 生日祝福语送老公简短