Convert StringBuilder To String

 In this example firstly create a string builder and then convert it to string using toString() method.

package com.javapro.string;

public class StringBuilderDemo {

public static void main(String[] args) {
StringBuilder data=new StringBuilder(“Hi”);
data.append(” How Are”);
data.append(” You”);

String str=data.toString();



Leave a Reply

Your email address will not be published. Required fields are marked *

8 + 2 =