Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.lang.reflect.Array;

public class Main {

    public static void main(String[] args) {

        String str = "This is from java2s.com";

        Class cls = str.getClass();
        boolean arr = cls.isArray();
        System.out.println(arr);

        Object array = Array.newInstance(int.class, 3);

        Class type = array.getClass();
        if (type.isArray()) {
            Class elementType = type.getComponentType();
            System.out.println("Array of: " + elementType);
            System.out.println("Array size: " + Array.getLength(array));
        }
    }
}