StringBuilder代码执行流程图
2018-02-25 13:05:45 36 举报
StringBuilder代码执行流程
作者其他创作
大纲/内容
yes
newCapacity = Integer.MAX_VALUE0x7fffffff
value = new char[str.length() + 16]count=0
super(16)
OutOfMemoryError()
expandCapacity(count + str.length)
no
value=new char[16]count=0
ensureCapacityInternal(count + str.length)
new StringBuilder(String str)
newCapacity = value.length * 2 + 2
super(str.length() + 16)
StiringBuilder代码执行流程
newCapacitycount + str.length?
new StringBuilder()
count+str.length0?
append(str)
count + str.lengthvalue.length?
newCapacity 0?
count += str.length
newCapacity = count + str.length
收藏
0 条评论
下一页