java中contains方法是判断是否存在包含关系,比如说a =[1,2,3,4], b=1那么a就包含b
contains返回的是布尔类型true 和false,包含的话就返回true,不包含的话就返回false
public class pratise { public static void main(String[] args) { // TODO Auto-generated method stub String a = "l love feng ye"; String b = "love"; boolean c = a.contains(b); System.out.println(a.contains(b)); //assertEquals(a.contains(b), "true"); assert(c)=true;//加断言 } }
输出结果是true
时间: 2024-10-25 06:39:34