Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

public class Main {
    public static void main(String[] args) {
        // Create a String object
        String s1 = new String("Hello");

        // Create a StringBuilder from of the String object s1
        StringBuilder sb = new StringBuilder(s1);

        // Append " Java" to the StringBuilder's content
        sb.append(" Java"); // Now, sb contains "Hello Java"

        // Get a String from the StringBuilder
        String s2 = sb.toString(); // s2 contains "Hello Java"

    }
}