Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.io.CharArrayWriter;

public class Main {
    public static void main(String[] args) throws Exception {
        CharArrayWriter chw = new CharArrayWriter();

        String str = "from java2s.com!";

        chw.write(str);

        // get array of character from the writer
        char[] ch = chw.toCharArray();

        // for each character in character array
        for (char c : ch) {

            // print character
            System.out.println(c);
        }

    }
}