When I create a new String in Java, is it initialized with null or with " "?

Posted by Sergio Tapia on Stack Overflow See other posts from Stack Overflow or by Sergio Tapia
Published on 2010-05-11T16:48:31Z Indexed on 2010/05/11 16:54 UTC
Read the original article Hit count: 243

Filed under:
|
|
|

Here's my test code:

String foo = new String(); System.out.println(foo);

The output is blank and a new line is written. Since I'm new to Java, I don't know whether it made a " " string, or nulls are handled as blank lines.

© Stack Overflow or respective owner

Related posts about java

Related posts about string