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) {
        int[] data = { 1, 2, 3, 4, 5 };

        // Copy data array to new arrays 
        int[] eData = new int[9];
        int[] tData = new int[2];
        System.arraycopy(data, 0, eData, 0, 5);
        System.arraycopy(data, 0, tData, 0, 2);

        System.out.println("Original  Array: " + Arrays.toString(data));
        System.out.println("Expanded Array: " + Arrays.toString(eData));
        System.out.println("Truncated  Array: " + Arrays.toString(tData));
    }
}