The most important question in interviews is when to use String, StringBuffer and StringBuilder.
What is the difference between String and String Buffer?
- If the content is fixed and do not change frequently , then we need to use String objects.
- If the content is not fixed but thread safety is required, the we need to use StringBuffer Objects.
- If the content is not fixed and thread safety is not required, then we can use StringBuilder objects.
Refer:
What is the difference between StringBuffer and StringBuilder?What is the difference between String and String Buffer?
No comments:
Post a Comment