Jai Janardhan

Jai Janardhan

41 Articles Published

Articles by Jai Janardhan

Page 5 of 5

What is string constant pool in Java?

Jai Janardhan
Jai Janardhan
Updated on 30-Jul-2019 976 Views

When you store a String asString str1 = "Hello";directly, then JVM creates a String object with the given value in a separate block of memory known as String constant pool.And whenever we try to create another String asString str2 = "Hello";JVM verifies whether any String object with the same value exists in the String constant pool, if so, instead of creating a new object JVM assigns the reference of the existing object to the new variable.And when we store String asString str = new String("Hello");using the new keyword, a new object with the given value is created irrespective of the ...

Read More
Showing 41–41 of 41 articles
« Prev 1 2 3 4 5 Next »
Advertisements