Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

Can String Buffer has a String constant pool in java?

user-image
Question added by Mohd shahnawaz khan , Associate Project , Cognizant Technology Solution
Date Posted: 2013/11/21
Vivek Dudani
by Vivek Dudani , Software Engineer / Senior Software Engineer , Mastercard

The answer is no. The whole idea behind using String Buffer is not to use string pool as that will make it behave like a normal String class if it uses string pool. String Buffer creates a new object in Heap.

pardeep kumar
by pardeep kumar , Senior R & D Engineer , Mavenir Systems

No,  String buffer do not have a String constant pool because String buffer is mutable class.

Where as String has constant pool because it is immutable in java.

More Questions Like This