2 Questions on StringBuffer
Ulf Zibis
Ulf.Zibis at gmx.de
Wed Mar 17 16:29:27 UTC 2010
Why there are 2 methods which do not use the super method, where I can't
see any difference? :
public synchronized char charAt(int index)
public synchronized void setCharAt(int index, char ch)
Wouldn't ensureCapacity better coded as follows? :
public void ensureCapacity(int minimumCapacity) {
if (minimumCapacity > value.length) synchronized {
ensureCapacity(minimumCapacity);
}
}
This would save the synchronization if there is nothing to do.
-Ulf
More information about the core-libs-dev
mailing list