Developing Java Software
Simon P. Chappell writes "It's good to learn a programming language, but it's a far better thing to learn to write programs in that language. What the world needs are less programming language books and more books on programming with the language of your choice. Enter Developing Java Software, 3rd edition by Russel Winder and Graham Roberts. Dr. Winder is the primary author and I became aware of this book when he mentioned it on the Groovy mailing list. Knowing him to be an intelligent and helpful member of the Groovy development team, I rushed to suggest that I could review it for him." Read the rest of Simon's review.
Developing Java Software (3rd edition)
author
Winder and Roberts
pages
885 (19 page index)
publisher
Wiley
rating
7/10
reviewer
Simon P. Chappell
ISBN
0470090251
summary
A good book for learning to write programs with Java.
Developing Java Software is a text book, and is targeted towards university undergraduates, most likely in some form of computer science curriculum. It is also completely suitable for self-learners who want to teach themselves how to write software in Java. The book has been used by the authors when teaching undergraduate classes at University College London, so it has been fully tested in the academic environment.
There are five parts, with twenty four chapters between the first four parts and ten appendixes in the fifth. Each of the chapters are short, most are less than 40 pages, tightly focused and fairly self-contained.
The first part, the longest of them all, starts out with the introduction chapter that no book is complete without. Really, how many people who want to learn Java don't know that it used to be called Oak and was originally designed for set-top boxes? Anyway, after that little excursion, the book moves onto useful stuff like "Programming Fundamentals", introducing concepts like statements, variables and expressions. Next is "Adding Structure" where we discover methods and control structures. Chapter four is "Introducing Containers" and does a good job of covering arrays and the whole slew of container data structure classes in the standard library. Chapter five is a little time off for good behaviour, where we get to spend some time "Drawing Pictures" before heading into chapter six for "Classes and Objects". Chapter seven explains "Class Relationships" while chapter eight introduces us to "Exceptions". Chapter nine is "Introducing Concurrency with Threads". We finish up with chapter ten covering "User Interfaces".
Part two addresses the "Process of Programming" and this is where it really differentiates itself from the rest of the Java book crowd. Chapter eleven gives an overview of "The Programming Process". Chapter twelve begins the process of making that real by addressing "Unit Testing". Chapter thirteen continues the story with "Test-driven Programming Strategies". More practical advice comes in chapter fourteen as they introduce the reader to "Programming Tools".
Part three brings two "Case Studies in Developing Programs". Chapter fifteen introduces the case studies. The first study, "Contacts Book" is in chapter sixteen and the second, a "Pedestrian Crossing Simulation" is in chapter seventeen.
Part four is "The Java Programming Language in Detail". This is the more reference portion of the book and it's seven chapters cover variables, types and expressions, flow-control, classes and packages, inheritance and interfaces, exception handling, threads and concurrency.
Part five is the "Endmatter" and holds ten appendixes.
The first thing to like with this book is that it has an engaging style. The style comes not just from the body text, but also from the notes, tips and references in the margins of the book. As someone who learned Java almost ten years ago, I have difficulty plowing through yet more body text explaining the same old stuff that every other Java book covers; yet, jaded and cynical as I am, I enjoyed the sparks of honesty and humour in the text.
As I alluded to in my opening remarks, this book takes the approach of trying to not only teach Java, but how to approach and actually write programs using Java. The book takes an iterative approach and emphasizes the use of testing tools. Interestingly, they use TestNG rather than the de facto standard JUnit. This is the first book that I've seen that uses TestNG; perhaps JUnit is finally getting some competition?
The book is completely targeted at Java 5. All of the code examples use the new features where appropriate. This makes the book worth considering for those that already know Java but want to finally climb onboard with the latest version.
Naturally, there is a website available at www.devjavasoft.org where all of the source code for the programs in the book may be downloaded, together with answers to the exercises and any updates or revisions of the material in the book.
One of the challenges of writing or updating a book of this size is that it's possible (nay, almost guaranteed) to miss important things. The tip at the top of page 190 is a classic example, where the reader is advised that calling System.gc() will force the Java Virtual Machine (JVM) to perform a garbage collection. This is not, and has never been, true. The most that the System.gc() call will do is let the JVM know that now would be a good time for it to garbage collect, but there are no guarantees that any collection will actually take place. With this being the third edition of the book, I expected errors of this sort to have been caught by now.
Another point to consider is that with this being a textbook the writing style is less like a mass-market book and it also includes questions and exercises at the end of each chapter. I normally avoid books of this sort, although this does seem to be one of the better ones.
I hate being picky about typography, especially with the average level being quite good these days, but this book is set in a smallish font for the amount of text on each page. It is a serif font, but I didn't find it the most comfortable to read. Also, and this is the most egregious fault in the whole book, the program listings are set in a proportional font! I could hardly believe it when I saw it. While I realize that the authors are unlikely to be responsible for the final font selections, I fear that it damages an otherwise strong book and does them a disservice.
This is a good book for learning Java. More importantly, it's a good book for learning to write programs with Java.
You can purchase Developing Java Software 3rd edition from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
Developing Java Software is a text book, and is targeted towards university undergraduates, most likely in some form of computer science curriculum. It is also completely suitable for self-learners who want to teach themselves how to write software in Java. The book has been used by the authors when teaching undergraduate classes at University College London, so it has been fully tested in the academic environment.
There are five parts, with twenty four chapters between the first four parts and ten appendixes in the fifth. Each of the chapters are short, most are less than 40 pages, tightly focused and fairly self-contained.
The first part, the longest of them all, starts out with the introduction chapter that no book is complete without. Really, how many people who want to learn Java don't know that it used to be called Oak and was originally designed for set-top boxes? Anyway, after that little excursion, the book moves onto useful stuff like "Programming Fundamentals", introducing concepts like statements, variables and expressions. Next is "Adding Structure" where we discover methods and control structures. Chapter four is "Introducing Containers" and does a good job of covering arrays and the whole slew of container data structure classes in the standard library. Chapter five is a little time off for good behaviour, where we get to spend some time "Drawing Pictures" before heading into chapter six for "Classes and Objects". Chapter seven explains "Class Relationships" while chapter eight introduces us to "Exceptions". Chapter nine is "Introducing Concurrency with Threads". We finish up with chapter ten covering "User Interfaces".
Part two addresses the "Process of Programming" and this is where it really differentiates itself from the rest of the Java book crowd. Chapter eleven gives an overview of "The Programming Process". Chapter twelve begins the process of making that real by addressing "Unit Testing". Chapter thirteen continues the story with "Test-driven Programming Strategies". More practical advice comes in chapter fourteen as they introduce the reader to "Programming Tools".
Part three brings two "Case Studies in Developing Programs". Chapter fifteen introduces the case studies. The first study, "Contacts Book" is in chapter sixteen and the second, a "Pedestrian Crossing Simulation" is in chapter seventeen.
Part four is "The Java Programming Language in Detail". This is the more reference portion of the book and it's seven chapters cover variables, types and expressions, flow-control, classes and packages, inheritance and interfaces, exception handling, threads and concurrency.
Part five is the "Endmatter" and holds ten appendixes.
The first thing to like with this book is that it has an engaging style. The style comes not just from the body text, but also from the notes, tips and references in the margins of the book. As someone who learned Java almost ten years ago, I have difficulty plowing through yet more body text explaining the same old stuff that every other Java book covers; yet, jaded and cynical as I am, I enjoyed the sparks of honesty and humour in the text.
As I alluded to in my opening remarks, this book takes the approach of trying to not only teach Java, but how to approach and actually write programs using Java. The book takes an iterative approach and emphasizes the use of testing tools. Interestingly, they use TestNG rather than the de facto standard JUnit. This is the first book that I've seen that uses TestNG; perhaps JUnit is finally getting some competition?
The book is completely targeted at Java 5. All of the code examples use the new features where appropriate. This makes the book worth considering for those that already know Java but want to finally climb onboard with the latest version.
Naturally, there is a website available at www.devjavasoft.org where all of the source code for the programs in the book may be downloaded, together with answers to the exercises and any updates or revisions of the material in the book.
One of the challenges of writing or updating a book of this size is that it's possible (nay, almost guaranteed) to miss important things. The tip at the top of page 190 is a classic example, where the reader is advised that calling System.gc() will force the Java Virtual Machine (JVM) to perform a garbage collection. This is not, and has never been, true. The most that the System.gc() call will do is let the JVM know that now would be a good time for it to garbage collect, but there are no guarantees that any collection will actually take place. With this being the third edition of the book, I expected errors of this sort to have been caught by now.
Another point to consider is that with this being a textbook the writing style is less like a mass-market book and it also includes questions and exercises at the end of each chapter. I normally avoid books of this sort, although this does seem to be one of the better ones.
I hate being picky about typography, especially with the average level being quite good these days, but this book is set in a smallish font for the amount of text on each page. It is a serif font, but I didn't find it the most comfortable to read. Also, and this is the most egregious fault in the whole book, the program listings are set in a proportional font! I could hardly believe it when I saw it. While I realize that the authors are unlikely to be responsible for the final font selections, I fear that it damages an otherwise strong book and does them a disservice.
This is a good book for learning Java. More importantly, it's a good book for learning to write programs with Java.
You can purchase Developing Java Software 3rd edition from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
This is a very ass-sucking review. The only criticism is the typeface? I bet that it's not *that* impressive of a book.
Rule #1. NEVER USE BASIC TYPES
Please use "Int" instead of "int"... A good JVM will run this code nearly as fast, but the added bonus is that you make your code way more generic. Java is not C++.
What a tepid review. You could have added that it's a great book for making sure your kitchen table doesn't wobble if one leg is short.
I think after checking this out more on Amazon.com I am going to pass on this particular book. Not only is it $65... $15 more than usual Wrox books (which I personally like) but it also seems to have a lot of condensed information with potentially useless programming situations... I find it hard to believe that the reviewer did not find much wrong with the book and only gave it an 7/10? If we convert that into a grading scale, obviously thats 70%... thats struggling to get points across, and will be adequate for basic points ofr JAVA 5. As a suggestion, I would love to see a review of a good JAVA 6 book, so I know what others have checked out, so I can make an educated decision on what my nice shiney new JAVA 6 book will be.
-- Josh
"Whoopie! Man, that may have been a small one for Neil, but that's a long one for me!" - Pete Conrad
It's good to learn a programming language, but it's a far better thing to learn to write programs in that language.
I would read the rest of the review, but I'm not sure I'd understand it.
...is Bruce Eckel's Thinking in Java which has already invented the idea displayed here. Thats why you'll see that this book (tij) doesn't fully go into the bare Jave code but mostly reflects on the things which really matter. Knowing what things like Objects are, why objects differ from primitives, etc. Being a Java enthousiast myself it still amazes me how many people "program in Java" yet never learned how to interpret the JDK documentation, especially the so called API documentation.
Anyway, the Thinking in Java book is both available for free download (see URL above) and if you wish a hardcopy (or the latest release) then you can also purchase it. In my opinion this is a much better book which is also presented in a more fair way.
chapter ten covering "User Interfaces".
Was the ink from the first printing dry before Chapter 10 became outdated and deprecated?
I only look human.
My mother is a halfling and my dad is an ogre, so that makes me an Ogreling
It's good to learn to write, but it's much harder to learn to write a good review.
Intron: the portion of DNA which expresses nothing useful.
This might be a good place to ask this question. The only Java EE 5 text that I have with me is the Java EE 5 Tutorial. Is there any other (More detailed, better written) book on the same topic that Slashdot readers can recommend?
Funny, I was reading that and thought to myself that it was overqualified. What they ought to say is It is good to learn many programming languages, but it is a far better thing to learn to write programs
How does the Slashdot Effect happen given that no slashdotters ever RTFA?
I can't disagree more. Most programmers already know programming pretty well, and don't need their books on specific programming languages to be diluted with general programming instruction. Each of us is a programming amateur just once (I hope), but learns many additional languages throughout his career, and I think we want those non-newbie books to be concise and get to the point.
Every new programmer must learn to program in some language, but we certainly don't need a large variety of books that cater to people at that stage of proficiency - just one or two good ones.
... is more skilled programmers. I learn new languages from the language specification. Once you know how to write code in one language, and you actually _understand_ what you are doing, picking up a new language is easy.
Any Java book that starts with explaining statements, control structures etc. without first explaining what an object and a class is, does not sound very promising. In the CS educators community there is a movement towards an 'objects-first' approach in teaching JAVA, or more precisily, OOP using JAVA. Any book that typically starts with a 'hello world' program completely misses the point. First teach what an object is, what a class is, only then say something about how you can make these objects work together. This seems to be a much more fruitful approach in teaching students how to think OO, and then to put their ideas into any programming language, which happens to be JAVA in many cases. For a very good book to use in a programming 101 class, see 'Objects First With Java' by Barnes&Kolling (Prentice Hall; 3rd edition; June 2006)
"It's good to learn a programming language, but it's a far better thing to learn to write programs in that language. What the world needs are less programming language books and more books on programming with the language of your choice"
Not really, I agree with Steve McConnell when in his book "Code Complete" (2nd edition) says that you shouldn't programm in a language but INTO a language.
Most of the important programming principles not on an specific language but on the way one use them. Don't limit your programming thinking only on the concepts that are supported automatically by your language. The best programmers think of what they want to do, and then they assess how to accomplish their objectives with the programming tools at their disposal. (McConnell 843)
Sigs are for morons... Wait a minute...
For a more indepth idea of what the continue keyword is see http://en.wikipedia.org/wiki/Continue_(Java)
The first example of the use of continue made me want to cry!
I only look human.
My mother is a halfling and my dad is an ogre, so that makes me an Ogreling
Yes, but what good is that if you don't know how to achieve enlightenment. Maybe what is really need is a book that teaches the Java language, AND how to go about the development process in a good way while using the Java language, AND how to achieve enlightenment while going about the development process in a good way while using the Java language. I mean, otherwise, what's the point? Or, on the other hand, maybe you just need a book that teaches Java.
Most programmers already know programming pretty well, and don't need their books on specific programming languages to be diluted with general programming instruction.
Depressingly many programmers could benefit from reading a good, non language specific, book on the general principles of software design. In my experience there are quite a few people out there who manage to screw up even elementary aspects of writing a Java class. You would also do well to keep in mind that the author of a programming book has to cater to more than just old hands like you. These books are read by inexperienced people as well and dropping them some hints on how to do things properly isn't necessarily the waste of the authors time it seems to be to you. Also, most authors do try to structure their books in a way that enables experienced people to skip the 'basics' chapters.
I'm not trying to speak negatively about this particular book's contents, but just comment generally in response to a previous poster's reply. I think what we need less of is books that tell us how to use API's and control structures and logic as such. What we really need is a shift in the way we're taught to program in schools to mimic real world software creation. This book would more appropriately been titled "How to Program in Java" because development in the real world is quite different from just learning the language specifics. Software development is more about the deadlines you need to meet for the customers end and the balance between the most technical solutions and the most feasible ones. Essentially it's about the efficiency you complete a task given constraints of time and resource. We should stop writing books that just walkthrough different languages, and start teaching students in a way that places them in team projects and make them collaborate to complete projects. My undergrad school had only ONE class that was designed in this fashion, yet I would say that almost 100% of my work existence operates in this reality.
My current favorite Java programming book is Java Concurrency in Practice by Broan Goetz and others. It's not for beginners, but if you really want to understand how to write multi-threaded code in Java you need to read this book. Several times, probably, because it's a tricky subject.
Other books I like for Java are Effective Java (though he needs to update it for Java 1.5) and Java Puzzlers.
I don't know of any books that are good descriptions of the Java 1.5 features for experienced programmers. Some people like Thinking in Java, but it seems pretty wordy to me. I originally learned Java from Java in a Nutshell but it's been something like 8 years, so I don't know if the newer editions are any good.
Disclaimer: some of the authors of these books are my co-workers, though I don't know them very well.
Comment removed based on user account deletion
I'm finally glad to see some truly wise words, not to be mistaken for the more popular cynical opinion I see. I have experienced this myself. With that said, I would hope the title reviewed does focus on how, as you appropriately quote, "accomplish their objectives with the programming tools at their disposal".
You might want to check out this cool new markup language called "HTML" (hypertext markup language). It will allow you to bold or italicize words, thus obviating the need for surrounding words with underscore characters to indicate emphasis.
Of course, if you're really 1337, you'll pretend you're on a terminal with non-destructive backspaces and use a construct like this^H^H^H^H____ for underlining.
Learn the libraries to write fast code. Don't concatenate, use StringBuffer-s. Don't use buffer.append("a" + "b") - kinda defeats the purpose :) . Don't copy arrays to add an element, use Vector/ArrayLists. Don't do linear search, use Hashtable/HashMap. Don't insert into sorted arrays/vectors, use TreeSet. Don't search inside a Vector, use HashSet. Learn how to write objects that can be hashtable keys (i.e. they must have proper equals() and hashCode()). Learn how to write objects that can be used inside Tree-s (i.e. they must be Comparable-s that have proper equals() and compareTo()). Learn how to make objects sortable or implement Comparable correctly.
Yeah, kinda basic but you will be amazed what kind of speed improvements you can get by learning these and using them whereever it is appropriate. With the proper data structure (most of them are already in the JDK) your app will fly.
Oh, and don't redraw AWT/Swing like crazy. That's why the app is so slow. Learn how to use invokeLater to avoid deadlocks/bad data, etc.
Learn how to synchronize properly with no deadlocks and what wait() and notify() are for.
Learn char and byte streams and learn memory streams (ByteArrayInput/OutputStream, etc).
Learn to love try-finally for dealing with streams.
Learn to log.
Learn by writing actual app code. Nothing beats that.
6/10 means "this book/movie is crap"
7/10 means "this book/movie is ok"
8/10 means "this book/movie is actually worth readign/seeing"
As a c programmer trying to learn Java I grabbed a couple of books and looked at a lot of online tutorials. The one book that really "opened it up" for me was O'Reilly's "Java Network Programming". Mostly because I was not the least bit interested in writing GUI apps and every other "learn to program Java" book I found figured all you really want to do is learn to write an MS Paint clone. I understand having a real life example to teach concepts (and OO programming in general was hard for me at first) but I have a hard time getting into it if I am totally disinterested in the examples. Network Programming just seemed to present everything better and used examples that I could see relevance in.
The way I learn now is by grabbing good code (various Apache java projects have a lot of good code in them) and reading it, while referencing Sun's online API docs.
Just my $0.02
Finkployd
You don't know as much as you think you know, especially about Strings. To begin with, I suggest you do some Google searches for the phrase "Premature optimization is the root of all evil." Now then...
You don't seem to be aware that the following two lines are either identical, or so close to identical in their execution that you will never be able to discern the difference with any debugger or benchmark:
System.out.println("The product of " + a + " and " + b + " is " + (a * b));
System.out.println(new StringBuffer("The product of ").append(a).append(" and ").append(b).append(" is ").append(a * b));
Details are here.
It is true that in Java 1.0, StringBuffer was always the better way to concatenate. But that was over ten years ago. Modern Java programmers know you don't use StringBuffer unless you're doing frequent concatenations (such as inside a loop). And professional programmers know that readability and maintainability are way more important than saving a few cycles in some logging statement.
Wrong. Concatenation of constants results in a single constant at compile time. In other words, the following lines will compile into byte-for-byte identical bytecode:
System.out.println("Today" + ' ' + "is" + " December " + 13);
System.out.println("Today is December 13");
Feel free to try it for yourself if you don't believe me.
The Internet is full. Go away.
You're correct, the key is to use libraries. But these days, Java is likely not the way to go. The Java class library is a mess, mostly due to Sun continually adding to it, while also retaining old classes for backwards compatibility. While they grafted some Java 5 features on (ie. generics), there are many places in Swing where static constants should be replaced with proper enumerations. Unfortunately, again due to backwards compatibility reasons Sun, can't do that.
The C++ STL offers much the same functionality as the Java class library, but often in a more sensible fashion. Combine it with the Boost libraries, and you've got yourself virtually unlimited power. You can take advantage of high-performance native binaries. In addition, C++ is far more portable than Java. C++ can be used on systems that Java doesn't have a (recent or decent) port to, including UnixWare, FreeBSD, NetBSD, OpenBSD, and a host of other systems. Not having to have your users install a 15 MB Java runtime is also a major benefit.
All major databases offer a C++ API. When it comes to GUI development, wxWidgets is fantastic, well-supported, portable, and frequently updated. You can also go with the excellent Qt framework, if you're willing to pay a bit (for commercial development). Apache puts out some high-quality XML parsing software. There are numerous networking libraries available for C++.
In the end, Java offers little benefit over C++. With the addition of garbage collection to the upcoming C++ standard, there will be basically no advantage to using Java.
Insane. It's as bad as SQL jsp tags.
In my University, I was taught general concepts: structures, recursion, iteration, abstractions, conditions, logic, programming paradigms, etc., never tied to a specific language. In fact, we used to use a pseudo-language to express solutions to problems.
Real languages (Pascal, X86 assembler, basic, fortran, C, Java, C++, scheme, SQL) were used only in lab practices. It was pre-supposed that you already knew them or you had the basic concepts to learn them.
Whenever I see that someone has been taught an specific language at the university (sometimes a whole semester!), I tend to think that this person will not be able to fullfil his/her position, because he/she has been taugth an specific technology instead of knowledge. It's like a doctor that has been taught how to operate certain medical device instead of how the human body works.
Learn principles and then you'll be able to tell which language is the best at the job.
And as a nice side effect, you'll always be able to catch up with whatever shows up in the ever changing madness of IT.
Most CS departments don't even own drums.
Markup languages are just file formats with delusions of grandeur.
Exactly why I use Integer over int in most cases. With int, you cannot have an undefined value, with Integer you can. Sometimes, the int/Integer may be optional. If there is data there (!= null) I can use it, else I won't. With an int, you can't do that check, it is always defined.
So, like most programming decisions, it all depends on your needs.
"It's good to learn a programming language, but it's a far better thing to learn to write programs in that language.
;-)
And more important than either of these is to be able to successfully modify programs in that language.
Very few of the jobs I've had in several decades of working as a programmer involved writing programs. Far more of the jobs in the real world consist of modifying a program that already exists, either to correct bugs or to add new features. This requires a very different set of tools and talents than developing the software from scratch.
Another way of expressing it is that we rarely actually write programs. Rather, we usually modify programs. And we do this with code that wasn't designed or developed to make modifications easy.
Let's face it; designing is easy. At least, the sort of design that typically comes out of all the methodological fads is easy. That's why people write so many books about it. But they hardly ever tackle the difficult part of programming, which is taking the results of a design and making it actually do what is now needed, which is slightly different from what was needed back then.
And java is one of the languages where the implementation of the design isn't usually done well. As with C++, designers think that their good design will make it all work. When it doesn't, perhaps because the task has changed, and the designers have moved on, the programmers are stuck with trying to make sense of what is often write-only code. It isn't documented, because you don't need that with a good design, right? And code in these languages usually have the property that no line can be understood by itself, because of all the things that are defined elsewhere. And those definitions can't be understood by themselves, because they use things defined elsewhere. Making even the simplest change usually requires a full understanding of every line of the program, because everything depends on everything else.
Maybe some day someone will write a good book on how to modify existing code successfully, without introducing more bugs than were there when you started. This is the really major technical advance that still seems over the horizon, even after decades of mostly bad experience with hacking other people's code.
(One of the most successful techniques I've stumbled across consists of constantly asking myself "What would I like this to look like when I come across it N years from now and want to make a few small changes?" You might be surprised by some of the common mistakes that this helps you avoid. And I've often been happy that I did that, N years after I wrote something.
Those who do study history are doomed to stand helplessly by while everyone else repeats it.
What the world needs is fewer programming language books.
I didn't want to get all Lynn Truss on the lad, but hey, if he can be picky about typography, I can be picky about grammar.
And the culprits are including both user reviews and reviews by professionals, where you would expect the quality of grades being better.
One scandinavian photo magazine, using 1 - 10 grades is actually so bad that you actually have to recalculate the grades. The grades almost always land in the 5 - 10 range, where 5 would mean utter crap. One pretty effective way of dealing with this is to subtract 5 from the original grade and use the result as a grade in the range 1 to 5. So far this "tactic" has worked pretty well.
One obvious reason for magazines and such not giving too low grades are the dependancy of manufacturers actually sending them stuff to review.
Ceterum censeo Microsoftem esse delendam
I'm not talking about this case, of course. I'm talking about generating a 1 mb XML file, for instance. :)
:) I said: learn about it. Don't memorize, learn.
As for "a" + "b" being evaluated in compile time - yes, but this isn't: (String)myArray.elementAt(i) + " at " + i.
See? I know
Actually, System.out.println("The product of " + a + " and " + b + " is " + (a * b)); compiles as System.out.println(new StringBuffer("The product of ").append(a).append(" and ").append(b).append(" is ").append(a * b));
Use StringBuffers or memory streams to build large bodies of text. Use concatenation for dumps / logs / UI (sometimes if you generate 100 UI items via concatenation, it's better to use a StringBuffer and call setLength(0) at the beginning of the loop). Seemed obvious when I was writing the original post.
ohhhh.... a budding flamewar over the best way to do string handling in Java!!!
*gets out popcorn and settles in to watch*
And don't forget about StringBuilder
Do you really need thread-safe access to your buffer?
Every little helps.
"There is nothing nice about Steve Jobs and nothing evil about Bill Gates." - Chuck Peddle
They required us once to use 1.1-compatible libraries (in an OSGI company), so that's stuck in my mind, but yes, you're right of course :) .