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");
System.out.println("data="+data);
String str=data.toString();
System.out.println("str="+str);
}
}
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");
System.out.println("data="+data);
String str=data.toString();
System.out.println("str="+str);
}
}
No comments:
Post a Comment