CodesJava

Easy learning with example program codes

what is string constant pool in java?


String literal/constant pool: is a special part of heap memory used to store string literals or string constants.
Every time a literal is created, JVM checks the string constant pool for it. If string literal is already in the pool then no new object will be created in the pool, a reference of the already existing object will returns. If string literal is not exist in the string constant pool then new instance will be created and placed in the string constant pool.
E.g. – String str1 = “javawithease”
String str2 = “javawithease”

Java interview questions on string handling

Sign Up/ Sign In
Ask a Question


Copyright © 2018 CodesJava DMCA.com Protection Status SiteMap Reference: Java Wiki