It's a pretty naive question to ask but I got this doubt while programming for Android. I use to initialize my new strings like String a=null
, so in my code there remains a probability to get NullPointerException
if I forget to initialize the variable before accessing it but what about the other case. Also which one should be used?
Java: difference between String a = null and String a = new String()
Rajat Saxena
- 121
- 1
- 1
- 7