j_capacity.java

来自「一个十分好的java基础学习的课件」· Java 代码 · 共 26 行

JAVA
26 行
字号
// ////////////////////////////////////////////////////////
// 
// J_Capacity.java

// ////////////////////////////////////////////////////////

public class J_Capacity
{

    public static void main(String args[])
    {
        StringBuffer b=new StringBuffer( );
        System.out.println("The length is " + b.length( ) + ", and the capacity is " + b.capacity( ));

        b.ensureCapacity(18);
        System.out.println("The length is " + b.length( ) + ", and the capacity is " + b.capacity( ));

        b=new StringBuffer("1234");
        System.out.println("The length is " + b.length( ) + ", and the capacity is " + b.capacity( ));

        b.ensureCapacity(60);
        System.out.println("The length is " + b.length( ) + ", and the capacity is " + b.capacity( ));
    } // End of method: main

} // End of class: J_Capacity

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?