[Java] startsWith(Prefix), endsWith(Suffix)

동민·2021년 7월 21일
0

1. String

String str = "hello world";

boolean test1 = str.startsWith("he"); // true
boolean test2 = str.startsWith("es"); // false

boolean test3 = str.endsWith("ld"); // true
boolean test4 = str.endsWith("he"); // false

2. StringUtils

String str = "hello world";

boolean test1 = StringUtils.startsWith(str, "he"); // true
boolean test2 = StringUtils.startsWith(str, "es"); // false

boolean test3 = StringUtils.endsWith(str, "ld"); // true
boolean test4 = StringUtils.endsWith(str, "he"); // false
profile
BE Developer

0개의 댓글