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