MainClass.java Source code

Java tutorial

Introduction

Here is the source code for MainClass.java

Source

class MainClass {
    public static void main(String[] args) {
        StringBuffer sb = new StringBuffer("abc");

        System.out.println("sb = " + sb);
        System.out.println("Length = " + sb.length());
        System.out.println("Capacity = " + sb.capacity());

        sb.setLength(2);

        System.out.println("sb = " + sb);
        System.out.println("Length = " + sb.length());
        System.out.println("Capacity = " + sb.capacity());

        sb.setLength(4);

        System.out.println("sb = " + sb);
        System.out.println("Length = " + sb.length());
        System.out.println("Capacity = " + sb.capacity());
    }
}