Java copy section of array

user1102901 picture user1102901 · May 3, 2012 · Viewed 49.7k times · Source

Is there a method that will copy a section of an array(not arraylist) and make a new array from it?

Example:
[1,2,3,4,5]

and you create a new array from it:

[1,2,3]

Are there any one line/methods that will do this?

Answer

Jeffrey picture Jeffrey · May 3, 2012

See the method Arrays.copyOfRange