Package com.day7.one;
public class DemoString1 {
/**
* @param args
* 1.boolean equals (Object obj) compares the contents of strings for the same, case-sensitive
* 2.boolean equalsignorecase (String str) compares string contents for same, case insensitive
* 3.boolean contains (string str) to determine if a small string is contained in a large string
* 4.boolean Startwith (string str) determines whether a string starts with a
* 5.boolean EndsWith (string str) determines whether a string is terminated with a string
* 6.boolean isEmpty () determine if the string is empty
*/
public static void Main (string[] args) {
String s1= "Kobebryant";
String s2= "";
String S3=null;
System.out.println (S1.isempty ()); False
System.out.println (S2.isempty ()); True
System.out.println (S3.isempty ()); Abnormal
/*
* "" and the difference between null
* "" is a string constant and is also an object of the string class, since the object can of course call a method in the String class
* Null is an empty constant, you cannot call any method, otherwise a null pointer exception will occur, and NULL can assign a value to any reference data type
* */
}
}
The java-string of each string in the class (including the difference between "" and null)