public class
test {
public static void main(String[] args) {
String x="hello world";
boolean status=x.contains("hello");
System.out.println(status);
}
}
输出结果:
true
二、判断字符串长度: length()
public class
test {
public static void main(String[] args) {
String x="hello world";
int l=x.length();
System.out.println(l);
}
}
三、截取字符串: substring()
public class
test {
public static void main(String[] args) {
String x="hello world";
System.out.println(x.substring(0,3));
}
}
输出:
hel