contains()
함수는 대상 문자열에 특정 문자열이 포함되어 있는지 확인하는 함수이다.대/소문자
를구분
한다.✅ 변수명.contains(찾고자 하는 값)
// [str "Hello"]에 "He"와 "say"가 포함되어 있는지 확인하라.
String str = "Hello";
System.out.println( str.contains("He") ); // true
System.out.println( str.contains("say") ); // false
// [str1 "Hello"]에 [str2 "He"]가 포함되어 있으면 [1], 그렇지 않으면 [2]를 출력한다.
String str1 = "Hello";
String str2 = "He";
System.out.println(str1.contains(str2) ? 1 : 2); // 출력값 : 1