• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
仅供参考
博客园    首页    新随笔    联系   管理    订阅  订阅
StringBuilder

StringBuilder bu = new StringBuilder();       StringBuilder bu2 = new StringBuilder();       StringBuilder bu4 = bu.append("cbd");       StringBuilder bu3 = bu.append("cbd");       bu.append(true);       System.out.println(bu);       System.out.println(bu2);                       String s = bu.toString();               public static void main(String[] args) {   // 构建StringBuilder对象   StringBuilder bu = new StringBuilder();// "" 0   // 调用insert方法   【System.out.println(bu.length());】   /*         if ((offset < 0) || (offset > length()))             throw new StringIndexOutOfBoundsException(offset);     */   【StringBuilder bu2 = bu.insert(0, "A");】   System.out.println(bu2);   System.out.println(bu == bu2);   System.out.println(bu2.length());   bu.insert(1, "B");   System.out.println("bu2:" + bu2);   // 插入一个布尔类型值   bu.insert(2, true);   System.out.println(bu);   System.out.println("bu字符串缓冲区的长度为:" + bu.length());   System.out.println("bu字符串缓冲区的容量大小为:" + bu.capacity());   Student student = new Student();   student.setAge(10);   student.setName("小王");   bu.insert(6, student);   System.out.println("=");   System.out.println(bu.length());   System.out.println(bu);   System.out.println("=");   【System.out.println(bu.capacity());// miniCapacity.lenght()】Integer.MAX_VALUE < minCapacity   // throw

posted on 2020-12-01 10:32  七0  阅读(55)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3