Full Stack Developer (Java) Question:

Explain me what is the difference between String, StringBuffer andStringBuilder?

Tweet Share WhatsApp

Answer:

String is an immutable class. In older JDK’s the recommendation when programmatically building a String was to use StringBuffer since this was optimized to concatenate multiple Strings together. However, the methods on StringBuffer were marked as sychronized, which meant that there was a performance penalty, hence StringBuilder was introduced to provide a non-synchronized way to efficiently concatenate and modify Strings.

Download Full Stack Developer (Java) PDF Read All 43 Full Stack Developer (Java) Questions
Previous QuestionNext Question
Explain me something About Your Favorite Language And Why?Please explain what is the contract between equals and hashCode of an object?