take a peice from array java

Java
import java.util.IntStream;
// for java 8 and 8+
IntStream.range(start, end).map(x -> arr[x]).toArray();
Source

Also in Java: