StringBuffer总结分析
构造方法
/**
* Constructs a string buffer with no characters in it and an
* initial capacity of 16 characters.
* 创建容量为16个char大小的空间
*/
public StringBuffer() {
super(16);
} /**
* Constructs a string buffer with no characters in it and
* the specified initial capacity.
*创建一个指定容量的StringBuffer对象
* @param capacity the initial capacity.
* @exception NegativeArraySizeException if the {@code capacity}
* argument is less than {@code 0}.
*/
public StringBuffer(int capacity) {
super(capacity);
} /**
*初始化一个有指定string的对象,空间大小为string.length+16
* 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.
*/
public StringBuffer(String str) {
super(str.length() + 16); //new char[str.length() + 16]
append(str);
}
append方法 如果string的长度大于capacity的增String会自动增加容量
StringBuffer总结分析的更多相关文章
- java_String和StringBuffer区别分析
JAVA平台提供了两个类:String和StringBuffer,它们可以储存和操作字符串,即包含多个字符的字符数据.这个String类提供了数值不可改变的字符串.而这个StringBuffer类提供 ...
- StringBuffer类和StringBuilder类
StringBuffer类和StringBuilder类 三者比较 String 不可变字符序列 底层用char[]存储 StringBuffer 可变的字符序列 线程安全的 效率低 底层结构使用ch ...
- 201421123042 《Java程序设计》第2周学习总结
1. 本周学习总结 以几个关键词描述本周的学习内容.并将关键词之间的联系描述或绘制出来. 原则:少而精,自己写.即使不超过5行也可,但请一定不要简单的复制粘贴. 引用类型 引用类型是指向一个对象,感觉 ...
- [源码]String StringBuffer StringBudlider(2)StringBuffer StringBuilder源码分析
纵骑横飞 章仕烜 昨天比较忙 今天把StringBuffer StringBulider的源码分析 献上 在讲 StringBuffer StringBuilder 之前 ,我们先看一下 ...
- String、StringBuffer、StringBuilder源码分析
利用反编译具体看看"+"的过程 1 public class Test 2 { 3 public static void main(String[] args) 4 { 5 int ...
- 【源代码】StringBuilder和StringBuffer震源深度分析
//------------------------------------------------------------------------ 写篇博客不easy.请尊重作者劳动成果. 转载请注 ...
- String、StringBuffer和StringBuilder区别及性能分析
1.性能比较:StringBuilder > StringBuffer > String 2.String <(StringBuffer,StringBuilder)的原因 S ...
- String,StringBuffer,StringBuilder的区别及其源码分析
String,StringBuffer,StringBuilder的区别这个问题几乎是面试必问的题,这里做了一些总结: 1.先来分析一下这三个类之间的关系 乍一看它们都是用于处理字符串的java类,而 ...
- Java StringBuilder 和 StringBuffer 源码分析
简介 StringBuilder与StringBuffer是两个常用的操作字符串的类.大家都知道,StringBuilder是线程不安全的,而StringBuffer是线程安全的.前者是JDK1.5加 ...
随机推荐
- c语言-折半查找的函数
void search(int n,int num[],char name[N][10]) { int top,bottom,middle,location,flag; top=0; bottom=N ...
- 海思的一个 Makefile 解析
Makefile 原文 include ../Makefile.param #ifeq ($(SAMPLE_PARAM_FILE), ) # SAMPLE_PARAM_FILE:=../Makefil ...
- rm: cannot remove `xxx’: Operation not permitted问题的处理方案
第一步:22.txt lsattr 22.txt 查看文件属性 看到的情况 -----a------- 第二步:去除a的属性 chattr -a 22.txt 第三步:在此执行删除 rm 22.txt
- getLong not implemented for class oracle.jdbc.driver.T4CRowidAccessor
症状: SpringMVC+MyBatis向数据库插入数据,主键应用ORACLE中自己设置的自增序列会发生如下错误: nested exception is Java.sql.SQLException ...
- Stack — 20181121
12. Min Stack public class MinStack { Stack<Integer> stack; Stack<Integer> minStack; pub ...
- dotnetCore增加MiddleWare的Run,Use Map MapThen四个扩展方法
dotnetCore增加MiddleWare的Run,Use Map MapThen四个扩展方法 http://www.mamicode.com/info-detail-1439628.html
- vue 无限级分类导航
递归组件,实现无限级分类导航 https://cn.vuejs.org/v2/guide/components-edge-cases.html#%E9%80%92%E5%BD%92%E7%BB%84% ...
- python3 zip压缩
参考: https://docs.python.org/3/library/zipfile.html https://zhidao.baidu.com/question/149840976436638 ...
- unity动态加载FBX模型(Http下载到Rescources文件,场景Load直接调用):
using UnityEngine; using System.Collections; using System.IO; using System.Net; using System; using ...
- python -ConfigParser模块讲解
configParser 模块用于操作配置文件 注:Parser汉译为“解析”之意. 配置文件的格式与windows ini文件类似,可以包含一个或多个节(section),每个节可以有多个参数(键= ...