48. Immutable string

Every programming language has a way of representing strings. As primitive types, strings are part of the predefined types, and they are used in almost every type of Java application.

In Java, strings are not represented by a primitive type like int, long, and float. They are represented by a reference type named String. Almost any Java application uses strings, for example, the main() method of a Java application gets as an argument an array of the String type.

The notoriety of String and its wide range of applications means we should know it in detail. Besides knowing how to declare and manipulate strings (for example, reverse, and capitalize) developers should understand why this class was designed in a special or different way. More precisely, why is String immutable? Or maybe this question has a better resonance formulated like this—what are the pros and cons of String being immutable?

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.51.153