This won't be anything new for the veteran Java programmer, but for those learning the language, having a few hard and fast rules that you can always depend on makes learning the language easier. Point your junior Java developers at this little advice column. It'll make them better programmers, unless of course, it doesn't make them better programmers; that's a promise.
An Immutable Law of Java: The new Keyword
-
Immutable Law of Java #20: The new Keyword (3 messages)
- Posted by: Cameron McKenzie ( @potemcam )
- Posted on: March 04 2011 11:05 EST
Threaded Messages (3)
- Re: Immutable Law of Java #20: The new Keyword by R.J. Byron on March 05 2011 12:32 EST
- postings by Cameron McKenzie ( @potemcam ) on March 06 2011 13:48 EST
- Immutable Law of Java #20: The new Keyword by James Watson on March 10 2011 16:44 EST
-
Re: Immutable Law of Java #20: The new Keyword[ Go to top ]
- Posted by: R.J. Byron
- Posted on: March 05 2011 12:32 EST
- in response to Cameron McKenzie ( @potemcam )
Why is this posted here?
-
postings[ Go to top ]
- Posted by: Cameron McKenzie ( @potemcam )
- Posted on: March 06 2011 13:48 EST
- in response to R.J. Byron
Should it not be?
-
Immutable Law of Java #20: The new Keyword[ Go to top ]
- Posted by: James Watson
- Posted on: March 10 2011 16:44 EST
- in response to Cameron McKenzie ( @potemcam )
When we go about telling people when they should or shouldn't do things, it's good to be complete:
[b]When to use new String()[/b]: If you calling substr on a potentially large string, and you do not want to keep the remaining parts of the large string, you should use new String() aroung the substr() call. If you do not, the entire backing array for the original (large) array will be retained in memory as long as the substr portion is not GC'd.