Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.io.CharArrayReader;

public class Main {
    public static void main(String[] args) throws Exception {

        char[] ch = { 'H', 'E', 'L', 'L', 'O' };

        char[] d = new char[5];

        CharArrayReader car = new CharArrayReader(ch);

        // read character to the destination buffer
        car.read(d, 3, 2);

        // for every character in the buffer
        for (char c : d) {
            int i = (int) c;
            if (i == 0) {
                System.out.println("0");
            } else {
                System.out.println(c);
            }
        }

    }
}