I understand the use cases of String Pool in java, but I am wondering what data structure is used while implementing String Pool. I mean when we talk about interning of strings, JVM needs to search the entire String Pool for any existing String. So how does this process is optimized?
Asked
Active
Viewed 103 times
1
-
String pool is just like a cache of strings using flyweight design pattern.. I think array would work just fine. – Shanu Gupta May 01 '18 at 11:41
-
@ShanuGupta But won't it will have a huge impact on time complexity? I mean searching an array for a string literal is too expensive. – pritamprasad May 01 '18 at 15:12