- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
On the third day of Christmas, my true love gave to me a ternary in a pair tree ...
Admin
I'll give you some slack since you've stated you haven't done Java in a while, but you really should read that web page again. The page actually proves that these two lines have nearly indistinguishable performance:
return "Pair(" + t + ", " + e + ")";
return new StringBuffer("Pair(").append(t).append(", ").append(e).append(")").toString();
Read the page more closely. StringBuffer is appropriate when you have repeated append operations, such as in a loop.
It is generally not appropriate to second-guess Java's + operator, which in fact works very well, particularly in a toString method.
Good programming isn't just about optimization, it's about how easy to read the code is.
Admin
You two OBVIOUSLY missed the real reason for the extra object. Where else would you put a partidge nest in a pair tree!
BOOM BOOM!
Admin
If it happened to be important, I can come up with a few plausable reasons:
Are any of these satisfactory?
Admin
WTF? I hit the random Random Article link, which then redirects me (randomly?) to this article over and over again. I know random doesn't mean different every time but, wtf?