The java-string of each string in the class (including the difference between "" and null)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.