以下实例判断 Runoob 中是否包含字符或字符系列:

实例

public class Main { public static void main ( String [ ] args ) { String myStr = " Runoob " ; System . out . println ( myStr . contains ( " Run " ) ) ; System . out . println ( myStr . contains ( " o " ) ) ; System . out . println ( myStr . contains ( " s " ) ) ;

以上程序执行结果为:

false

Java String类 Java String类