String
String的 判断功能:
boolean equals(object obj): 比较字符串的内容是否相同,区分大小写
boolean equalsIgnoreCase(String str) : 比较字符串的内容是否相同 , 忽略大小写
boolean contains (String str) : 判断大字符串中是否包含小字符串
boolean startsWith ( String str) : 判断字符串是否以某个指定的字符串开头
boolean endsWith (String str): 判断字符串是否以某个指定的字符串结尾
boolean isEmpty ( ) : 判断字符串是否为空
String s=“”;字符串的值为空
String s=null; 字符串的对象不存在
public static void main(String[] args) {
// TODO 自动生成的方法存根
String s="helloworld";
String s2="helloworld";
String s3="Helloworld";
//boolean equals(object obj): 比较字符串的内容是否相同,区分大小写
System.out.println(s.equals(s2));
System.out.println(s.equals(s3));
System.out.println("-------------------");
//boolean equalsIgnoreCase(String str) : 比较字符串的内容是否相同 , 忽略大小写
System.out.println(s.equalsIgnoreCase(s3));
System.out.println("-------------------");
// boolean contains (String str) : 判断大字符串中是否包含小字符串
System.out.println(s.contains("he"));
System.out.println("-----------------------");
// boolean startsWith ( String str) : 判断字符串是否以某个指定的字符串开头
System.out.println(s.startsWith("h"));
System.out.println("----------------------");
// boolean endsWith (String str): 判断字符串是否以某个指定的字符串结尾
System.out.println(s.endsWith("d"));
System.out.println("---------------------");
//boolean isEmpty ( ) : 判断字符串是否为空
System.out.println(s.isEmpty());
}