String[] array = new String[]{ "1", "2", "3" }; String[] output1 = Arrays.stream(array).skip(1).toArray(String[]::new); String[] output2 = Arrays.stream(array).limit(2).toArray(String[]::new); String[] output3 = Arrays.stream(array).skip(1).limit(1).toArray(String[]::new); System.out.println(String.join(", ", output1)); System.out.println(String.join(", ", output2)); System.out.println(String.join(", ", output3));
Output:
2, 3 1, 2 2