Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.io.*;

public class Main {

    public static void main(String[] args) {
        char[] c1 = { 'h', 'e', 'l', 'l', 'o' };
        char[] c2 = { 'w', 'o', 'r', 'l', 'd' };

        Writer writer = new PrintWriter(System.out);

        try {
            // write a char array
            writer.write(c1);

            // flush the writer
            writer.flush();

            // write a new char array
            writer.write(c2);

            // flush the stream again
            writer.close();

        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
}