Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.Arrays;

public class Main {

    public static void main(String[] args) {

        short[] arr1 = new short[] { 1, 10, 25 };

        System.out.println(Arrays.toString(arr1));

        // copying array arr1 to arr2 with newlength as 5 as Object
        Object arr2 = Arrays.copyOf(arr1, 5);

        // cast arr2 as short in order to be printable
        short[] arr3 = (short[]) arr2;

        System.out.println(Arrays.toString(arr3));
    }
}