Java Unit Tuple 的 contains() 方法
要搜索 JavaTuples 中 Unit 类的值,请使用 contains() 方法。
让我们首先看看使用 JavaTuples 需要满足哪些条件。要使用 JavaTuples 中的 Unit 类,您需要导入以下包 −
import org.javatuples.Unit;
注意 − 下载和运行 JavaTuples 程序的步骤如果您使用 Eclipse IDE 在 Java Tuples 中运行 Unit 类,则右键单击**Project → Properties → Java Build Path → Add External Jars**并上传下载的 JavaTuples jar 文件。
以下是示例 −
示例
import org.javatuples.Unit;
public class Demo {
public static void main(String[] args) {
Unit < String > u = Unit.with("Professional!");
// Search for an element
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!");
// Search for an element
boolean valSearch = u.contains("Desktop!");
System.out.println("Is the value in the Unit? " + valSearch);
}
}输出
Is the value in the Unit? False
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP