Explore Courses Blog Tutorials Interview Questions
0 votes
in Java by (10.2k points)

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

I have written some simple code:

String a = "";

String b = null;

System.out.println(a == b); // false

System.out.println(a.equals(b)); // false

Both statements return false. It seems, I am not able to find what is the actual difference between them.

1 Answer

0 votes
by (46k points)

String is an Object and can be null

null means that the String Object was not instantiated

"" is an actual value of the instantiated Object String like "aaa"

Here is a link that might clarify that point

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Nov 25, 2019 in Java by Anvi (10.2k points)
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

30.5k questions

32.5k answers


108k users

Browse Categories