10.9k views
4 votes
To convert a StringBuilder object to a String, you can use

a. the ToString() method of the StringBuilder object
b. the ToString() method of the Convert class
c. the Parse() method of the String class
d. the Parse() method of the StringBuilder object

1 Answer

2 votes

Final answer:

To convert a StringBuilder object to a String, use the ToString() method of the StringBuilder object.

Step-by-step explanation:

To convert a StringBuilder object to a String, you can use the ToString() method of the StringBuilder object. The correct answer in this case is option a. The ToString() method returns a string representing the contents of the StringBuilder object. Here is an example:

StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("Hello");
stringBuilder.append("World");
String result = stringBuilder.toString();

In the example above, the StringBuilder object is converted to a String using the toString() method.

User Igor Chubin
by
8.2k points