The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
October 2001

Advertisement

Advertisement

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.

Message:

a "gotcha" I have seen with String initialisation

Posted by Jody Brown on October 31, 2001 at 7:57 AM

I think Matt has summed it up very nicely. One other thing that I have noticed once or twice in my Java development career is code along the lines of:-

String myString = "" + someArbitaryObject.getArbitaryValue();

If the method getArbitaryValue() returns a null, you will get a string object created with the value "null". This has caused me hours of fun trying to debug code like this in the past, so it's worth watching out for.



Replies:

Sponsored Links



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