-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathStringArrayUtils.java
More file actions
26 lines (21 loc) · 956 Bytes
/
StringArrayUtils.java
File metadata and controls
26 lines (21 loc) · 956 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package com.dtcc.exams.arrays;
import java.util.Arrays;
public class StringArrayUtils {
/**
* @param arrayToBeSpliced - array to be evaluated
* @param startingIndex - starting index of array to be spliced
* @param endingIndex - ending index of array
* @return an array with all elements between `startingIndex` and `endingIndex`
*/
public static String[] getSubArray(String[] arrayToBeSpliced, int startingIndex, int endingIndex) {
return Arrays.copyOfRange(arrayToBeSpliced, startingIndex,endingIndex + 1);
}
/**
* @param arrayToBeSpliced - array to be evaluated
* @param startingIndex - starting index of array to be spliced
* @return an array all elements between after `startingIndex`
*/
public static String[] getEndingArray(String[] arrayToBeSpliced, int startingIndex) {
return Arrays.copyOfRange(arrayToBeSpliced, startingIndex, arrayToBeSpliced.length);
}
}