If you create a string using quotes, the newly created object is automatically placed in a String pool. The String pool is a special section in memory that stores a set of unique strings. Whenever you create a new instance of the String class using quotes, the virtual machine looks for an equal string in the String pool and returns the found instance (if an instance exists). If an equal object isn't found, then a new instance is placed in the String pool before returning a reference to it. If you receive a new string from the outside, as in the following example, you can use the intern() method to push a string value to the String pool:
val firstLine: String
get() = File("input.txt")
.inputStream()
.bufferedReader()
.use { it.readLine() }
The following example shows that whenever you read the firstLine property...