Difference between null and empty (“”) Java String

前端 未结 22 1686
再見小時候
再見小時候 2020-11-22 17:10

What is the difference between null and the \"\" (empty string)?

I have written some simple code:

String a = \"\";
String b         


        
22条回答
  •  难免孤独
    2020-11-22 17:43

    here a is an Object but b(null) is not an Object it is a null reference

    System.out.println(a instanceof Object); // true
    
    System.out.println(b instanceof Object); // false
    

    here is my similar answer

提交回复
热议问题