📄 buffertest2.java
字号:
class BufferTest2 {
public static void main(String[] args) {
// 自动产生
StringBuffer buffer= new StringBuffer("How are you?");
//display the information of capacity.
System.out.println("字符串容量是: "+buffer.capacity()+"。\n");
//display the information of length.
System.out.println("字符串的长度是"+buffer.length()+".\n");
//display the usage of setLength() method.
buffer.setLength(100000);
System.out.println("用过方法 setLength(1000) 后");
System.out.println("此时字符串的长度是: "+buffer.length()+"。");
buffer.setLength(4);
System.out.println("用过方法 setLength(4) 后");
System.out.println("此时长度是: "+ buffer.length()+"。");
//display the usage of charAt() method.
System.out.println("\n方法 charAt() 的使用。");
System.out.println("使用了 charAt(2):"+buffer.charAt(2)+" 。");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -