1StringBuilder stringBuilder = new StringBuilder();
2
3stringBuilder.append("string");
4
5System.out.println("String = " + stringBuilder.toString());
1Java StringBuilder class is used to create
2 mutable (modifiable) string. The Java
3 StringBuilder class is same as StringBuffer
4 class except that it is non-synchronized.
5
6StringBuilder()
7 creates an empty string Builder with the initial capacity of 16.
8StringBuilder(String str)
9 creates a string Builder with the specified string.
10StringBuilder(int length)
11 creates an empty string Builder with the specified capacity as length.
12
13StringBuilder builder = new StringBuilder("Harvard");
14// mutable you modify object new keyword ile olusturuoyrsun StringBuilder
15 builder.append(" School");
16// append method we are calling from Builder
17//** it is not synchronized means fast
18 System.out.println(builder); // Harvard School
1Java StringBuilder class is used to create
2 mutable (modifiable) string. The Java
3 StringBuilder class is same as StringBuffer
4 class except that it is non-synchronized.
5
6StringBuilder()
7 creates an empty string Builder with the initial capacity of 16.
8StringBuilder(String str)
9 creates a string Builder with the specified string.
10StringBuilder(int length)
11 creates an empty string Builder with the specified capacity as length.