138k views
4 votes
To alter just one character in a StringBuilder, you can use the ____ method, which allows you to change a character at a specified position within a StringBuilder object.

a.
insert()

b.
setCharAt()

c.
append()

d.
charAt()

User Deerawan
by
5.4k points

1 Answer

5 votes

Answer:

setCharAt()

Step-by-step explanation:

StringBuilder is a dynamic object that allow to create the string with no size restriction.

To answer the question, let discuss each option.

Option a: insert()

insert function is used to insert the element at the specific location but it does not change the rest of the character.

Option b: setCharAt()

it is used to change the value at specific location, it takes two argument location and character.

Option c: append()

it is used to connect the two string but it does not change the rest of the character.

Option c: charAt()

it is used to get the character at specific location. it does not allow the change.

Therefore, option b is correct option.

User Naveen Rao
by
5.3k points