StringBuilder
suggest changeVersions
The java.lang.StringBuilder class has been part of Java SE since 5.
Introduction
The Java StringBuilder class is used to create a mutable (modifiable) string. The Java StringBuilder class is the same as the StringBuffer class except that it is non-synchronized. It is available since JDK 1.5.
Syntax
- new StringBuilder ()
- new StringBuilder (int capacity)
- new StringBuilder (CharSequence seq)
- new StringBuilder (StringBuilder builder)
- new StringBuilder (String string)
Remarks
Creating a new StringBuilder with type char as a parameter would result in calling the constructor with argument int capacity and not the one with argument String string:
StringBuilder v = new StringBuilder('I'); //'I' is a character, "I" is a String.
System.out.println(v.capacity()); // output 73
System.out.println(v.toString()); // output nothing
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents