如何测试字符串是否在 Java 中包含特定单词?
只有且当此字符串包含指定的字符值序列时,java.lang.String.contains() 方法才会返回 true。
示例
public class Sample {
public static void main(String args[]){
String str = "Hello how are you welcome to tutorialspoint";
String test = "tutorialspoint";
Boolean bool = str.contains(test);
System.out.println(bool);
}
}输出
true
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP