MainClass.java Source code

Java tutorial

Introduction

Here is the source code for MainClass.java

Source

public class MainClass {
    public static void main(String args[]) {
        String s1 = "hello there";
        char charArray[] = new char[5];

        System.out.printf("s1: %s", s1);

        for (int count = s1.length() - 1; count >= 0; count--)
            System.out.printf("%s ", s1.charAt(count));

        // copy characters from string into charArray
        s1.getChars(0, 5, charArray, 0);
        System.out.print("\nThe character array is: ");

        for (char character : charArray)
            System.out.print(character);
    }
}