Se si passa attraverso con questo link questo può cancellare più Oracle Docs String Builder Buffer Capacity
Ora si vuole dichiarare la capacità di qualsiasi classe StringBuilder, quindi un costruttore StringBuilder(int initCapacity)
è definito per questo.
StringBuilder(int initCapacity)
:- Creates an empty string builder with the specified initial capacity.
qui a causa del parametro come int
la capacità massima che una classe può StringBuilder
è raggiungere sarà 2147483647
.
ci sono vari metodi per questo contesto di Capacità nella classe StringBuilder
, tali metodi considerano anche i parametri di tipo int
.
void setLength(int newLength) :- Sets the length of the character sequence. If newLength is less than length(), the last characters in the character sequence are truncated. If newLength is greater than length(), null characters are added at the end of the character sequence.
void ensureCapacity(int minCapacity) :- Ensures that the capacity is at least equal to the specified minimum.
questi metodi richiede anche come argomento di int
tipo. Quindi, utilizzando questi metodi o controsoff puoi generare un oggetto con capacità massima di 2147483647
.
fonte
2016-06-28 05:39:54
e cosa succede se supera il limite massimo? –