String connection pool
String connection pool
So today I got to learn a very interesting topic STRING CONNECTION POOL, what it means? well whenever we are dealing with strings this topic comes, so earlier it was in Method area until 1.6 version, but after 1.7 onwards it got to heap area, so that we can increase the size or decrease,
now whenever we are creating an object like String Variable1 = new String("Name"); then 2 objects are been created, one because of new keyword in heap and other Name in SCP or string litreal pool, now if we create one more variable String Variable2 = new String("Name"); then only 1 object will be created and that object will be created only in heap area, not in SCL becuase it already exists.(JVM does some internal working to point it to that same variable) if we create a String like String variable3 = "yoyo"; then only the object will be created in SCL not in heap area, which is why it's called strings are immutable. and in SCL garbage collection are not allowed because of JVM indirectly it points to the SCL. and if same variable string is made then it will point to that same value which is yoyo in SCL a new will not be created.