Strings and the Compiler

As mentioned earlier, there's no escaping strings in Java programs. In fact, you should embrace them. There is, however, an issue of having too many String instances around in an application, just like there's an issue of having too much of any objects around in memory. If you have ever used a performance tool on a Java application, you have definitely noticed the large number of objects and especially String in the application. Of course, this is entirely dependent on the application and the circumstance. Having too many instances alive in memory and relying on the garbage collection process to clean them up is not the best approach. Just be aware that because a String is an object just like any other, it takes up memory ...

Get Special Edition Using Java 2 Standard Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.