How to create a sub array from another array in Java?

前端 未结 9 550
醉话见心
醉话见心 2020-11-29 16:02

How to create a sub-array from another array? Is there a method that takes the indexes from the first array such as:

methodName(object array, int start, int          


        
9条回答
  •  天涯浪人
    2020-11-29 16:30

    Use copyOfRange method from java.util.Arrays class:

    int[] newArray = Arrays.copyOfRange(oldArray, startIndex, endIndex);

    For more details:

    Link to similar question

提交回复
热议问题