Proper string pooling
Our overarching concern is to ensure that our Java applications perform at a high level. To that end, memory management is a critical concern. It is important that we design, test, and implement techniques for optimizing memory usage. String pooling is one such technique, whose focus is to enable the reuse of string objects for greater application efficiency. The efficiency gains stem from reducing memory overhead.
String pooling is an important concept that is anchored to the sharing of string values as an alternative to creating new string instances. If your application uses string literals frequently, then you should find string pooling especially useful.
String literal
A string literal is a fixed value bookended by double quotes. For example, the "Read more books."
component of the following statement is a string literal:
System.out.println("Read
more books.");
To examine string pooling, we will start with the concept of...