What is Java String interning?

http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#intern() Basically doing String.intern() on a series of strings will ensure that all strings having same contents share same memory. So if you have list of names where ‘john’ appears 1000 times, by interning you ensure only one ‘john’ is actually allocated memory. This can be useful to reduce memory requirements of your program. But … Read more

What is Java String interning?

http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#intern() Basically doing String.intern() on a series of strings will ensure that all strings having same contents share same memory. So if you have list of names where ‘john’ appears 1000 times, by interning you ensure only one ‘john’ is actually allocated memory. This can be useful to reduce memory requirements of your program. But … Read more

What is Java String interning?

http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#intern() Basically doing String.intern() on a series of strings will ensure that all strings having same contents share same memory. So if you have list of names where ‘john’ appears 1000 times, by interning you ensure only one ‘john’ is actually allocated memory. This can be useful to reduce memory requirements of your program. But … Read more