Java examples for Collection Framework:Array Length
get Part Of Array by start and length
//package com.java2s; public class Main { public static void main(String[] argv) throws Exception { Object[] array = new String[] { "1", "abc", "level", null, "java2s.com", "asdf 123" }; int len = 2; System.out.println(java.util.Arrays.toString(getPartOfArray(array, len)));//from w ww . j av a 2s. com } public static Object[] getPartOfArray(Object[] array, int len) { return getPartOfArray(array, 0, len); } public static Object[] getPartOfArray(Object[] array, int start, int len) { Object[] newArray = new Object[len]; for (int i = start; i < start + len; i++) { newArray[i - start] = array[i]; } return newArray; } }