如何在 Java 中確定一個字串是否包含另一個字串?
java.lang.String.contains() 方法僅當此字串包含指定的 char 值序列時返回 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
廣告