There are different types of StringBuilder constructor in Java, they are as follows:
- StringBuilder(): This constructs a string builder with no characters in it and has an initial capacity of 16 characters.
StringBuilder str = new StringBuilder();
- StringBuilder(int capacity): Constructs a string builder with no characters in it and an initial capacity specified by the capacity argument.
StringBuilder str = new StringBuilder(10);
- StringBuilder(CharSequence seq): Constructs a string builder that contains the same characters as the specified CharSequence.
StringBuilder str1 = new StringBuilder("AAABBCCCDDEE");
- StringBuilder(String str): Constructs a string builder initialized to the contents of the specified string.
StringBuilder str = new StringBuilder(str1);
These are the constructors. Hope this helps.