The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
October 2001



This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.


Help asap!

Posted by Hiran on October 30, 2001 at 10:10 PM

Quick question. Are the following lines equivalent?
(1) String p = new String();
(2) String p = null;
(3) String p = "";
If they are not all equivalent, which ones are? Or are they all different? If so, what does each one print out? I'm asking cause at times I need to print a string that contains null (if a certain condition is not met, otherwise the string contains stuff). Thnx in advance!


Sponsored Links

Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us