JAVA empty string concatenation of String objects

JSONObject get used today in the absence of a line and finally assembled into sql statement when inserted into the database, the database is the last string of 'null', rather than an empty object.

Track for a long time only to find their java white school.

java string when the string concatenation is null

public class HelloWorld {
    public static void main(String args[]) {
        String s = null;
        s = s+"word";
        System.out.println("hello " +s);  //输出hello nullword
    }
}

 

Specific reference:

Java String fault tolerance of the null object

 

Guess you like

Origin www.cnblogs.com/huanghongbo/p/12028752.html