What is the use of string buffer class?

1 answer

Answer

1206461

2026-07-11 02:50

+ Follow

Java
Java

Strings are extremely useful but at the same time resource intensive too. In programs where numerous strings are used which need to be altered every now and then, it is advisable to use the StringBuffer or the StringBuilder class.

The Java.lang.StringBuffer and Java.lang.StringBuilder classes should be used when you have to make a lot of modifications to strings of characters. As we discussed in the previous chapter, String objects are immutable, so if you choose to do a lot of manipulations with String objects, you will end up with a lot of abandoned String objects in the String pool. On the other hand, objects of type StringBuffer and StringBuilder can be modified over and over again without leaving behind a great list of discarded String objects.

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.