I recently discovered that the java.lang.String.substring method does not return a new string, but is the original string, which was subscript. This may have memory implications. For example, if you read the ascii file and parse the tokens in the file using a substring and store the result of the substring in memory somewhere - what you actually save in memory is a whole line before the substring operation! You can, of course, solve this by wrapping the substring in your own version, which returns a new line of the substitution result.
source
share