阅读背景:

有多少人被Java子串内存问题所困扰?

来源:互联网 

I recently discovered that the java.lang.String.substring method does not return a new string, but a view of the original string that was substringed. This can have memory implications. For example, if you're reading an ascii file, and parsing tokens in the file using substring and storing the result of substring in memory somewhere -- what you're actually storing in memory is the entire string prior to the substring operation! You can of course solve this by wrapping substring in your own version that returns a new string of the subtring result.I recently discovered that the java.lang.String




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: