/** * Constructs a string builder with no characters in it and an * initial capacity of 16 characters. */ @HotSpotIntrinsicCandidate publicStringBuilder() { super(16); }
/** * Constructs a string builder with no characters in it and an * initial capacity specified by the {@code capacity} argument. * * @param capacity the initial capacity. * @throws NegativeArraySizeException if the {@code capacity} * argument is less than {@code 0}. */ @HotSpotIntrinsicCandidate publicStringBuilder(int capacity) { super(capacity); }
/** * Constructs a string builder initialized to the contents of the * specified string. The initial capacity of the string builder is * {@code 16} plus the length of the string argument. * * @param str the initial contents of the buffer. */ @HotSpotIntrinsicCandidate publicStringBuilder(String str) { super(str.length() + 16); append(str); }
/** * Constructs a string builder that contains the same characters * as the specified {@code CharSequence}. The initial capacity of * the string builder is {@code 16} plus the length of the * {@code CharSequence} argument. * * @param seq the sequence to copy. */ publicStringBuilder(CharSequence seq) { this(seq.length() + 16); append(seq); } }
/** * A cache of the last value returned by toString. Cleared * whenever the StringBuffer is modified. */ privatetransient String toStringCache;
/** use serialVersionUID from JDK 1.0.2 for interoperability */ staticfinallongserialVersionUID=3388685877147921107L;
/** * Constructs a string buffer with no characters in it and an * initial capacity of 16 characters. */ @HotSpotIntrinsicCandidate publicStringBuffer() { super(16); }
/** * Constructs a string buffer with no characters in it and * the specified initial capacity. * * @param capacity the initial capacity. * @throws NegativeArraySizeException if the {@code capacity} * argument is less than {@code 0}. */ @HotSpotIntrinsicCandidate publicStringBuffer(int capacity) { super(capacity); }
/** * Constructs a string buffer initialized to the contents of the * specified string. The initial capacity of the string buffer is * {@code 16} plus the length of the string argument. * * @param str the initial contents of the buffer. */ @HotSpotIntrinsicCandidate publicStringBuffer(String str) { super(str.length() + 16); append(str); }
/** * Constructs a string buffer that contains the same characters * as the specified {@code CharSequence}. The initial capacity of * the string buffer is {@code 16} plus the length of the * {@code CharSequence} argument. * <p> * If the length of the specified {@code CharSequence} is * less than or equal to zero, then an empty buffer of capacity * {@code 16} is returned. * * @param seq the sequence to copy. * @since 1.5 */ publicStringBuffer(CharSequence seq) { this(seq.length() + 16); append(seq); } @Override publicsynchronizedintcompareTo(StringBuffer another) { returnsuper.compareTo(another); }