java array shorten

java array shorten
Arrays.copyOfRange(array, start, end);
Source:w‮al.ww‬utturi.com

Copy the specified range of the specified array into a new array in java.

example:

/**
 * @author lautturi.com
 * Java example: Shorten array in java
 */
import java.util.*;

public class Lautturi {

	public static void main(String[] args) {
		int[] numArray = { 11,4,12,7,55,8,12,8,13,55,12,7 };
		int[] newArray = Arrays.copyOfRange(numArray, 2, 8);
		
		System.out.println(Arrays.toString(newArray));
		
	}
}

output:

[12, 7, 55, 8, 12, 8]
Created Time:2017-09-19 11:54:43  Author:lautturi