Last active
September 29, 2019 19:36
-
-
Save markruler/1f8a494d38c1f1bb624c63d7c9233c2f to your computer and use it in GitHub Desktop.
StringBuilder vs. StringBuffer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public AbstractStringBuilder append(String str) { | |
if (str == null) | |
return appendNull(); | |
int len = str.length(); | |
ensureCapacityInternal(count + len); | |
str.getChars(0, len, value, count); | |
count += len; | |
return this; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public final class StringBuffer | |
extends AbstractStringBuilder | |
implements java.io.Serializable, CharSequence { | |
/* ... */ | |
@Override | |
public synchronized StringBuffer append(String str) { | |
toStringCache = null; | |
super.append(str); | |
return this; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public final class StringBuilder | |
extends AbstractStringBuilder | |
implements java.io.Serializable, CharSequence { | |
/* ... */ | |
@Override | |
public StringBuilder append(String str) { | |
super.append(str); | |
return this; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment