标签:http system jdk 长度 package logs sys image UI
os :windows7 x64
jdk:jdk-8u131-windows-x64
ide:Eclipse Oxygen Release (4.7.0)
code:
package jizuiku0; public class Demo00 { public static void main(String[] args) { //无参构造 StringBuffer sb = new StringBuffer();//看API手册+源码可得,初始容量为16 System.out.println(sb.toString()); System.out.println(sb.length());//实际长度:0 System.out.println(sb.capacity());//capacity容量:16 System.out.println("-------------------------"); //指定capacity构造 StringBuffer sb1 = new StringBuffer(50);//看API手册+源码可得,初始容量为50 System.out.println(sb1.toString()); System.out.println(sb1.length());//实际长度:0 System.out.println(sb1.capacity());//capacity容量:50 System.out.println("-------------------------"); //指定字符串构造 StringBuffer sb2 = new StringBuffer("jizuiku");//看API手册+源码可得,初始容量为str.length()+16 System.out.println(sb2.toString()); System.out.println(sb2.length());//实际长度:7 System.out.println(sb2.capacity());//capacity容量:7+16 } }
result:
Java优秀,值得学习。
学习资源:API手册+Java源码+清净的心地。
标签:http system jdk 长度 package logs sys image UI
原文地址:http://www.cnblogs.com/jizuiku/p/7469544.html