TreeSet<String> s = new TreeSet<>(Arrays.asList(a)); s.removeAll(Arrays.asList(b)); if (s.size() != a.length) { return s.toArray(new String[s.size()]); } else { return a;
if (first < 0 || last < 0 || first >= source.length || last >= source.length) throw new ArrayIndexOutOfBoundsException(); List<T> result = new ArrayList<T>(); for (int i = first; i <= last; i++) result.add(source[i]); return result;
boolean[] tempArray = new boolean[length]; try { System.arraycopy(array, fromIndex, tempArray, 0, tempArray.length); } catch (ArrayIndexOutOfBoundsException e) { System.out.println("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"); System.out.println("Array of length:" + array.length); System.out.println("From index with length:" + fromIndex + "," + length); System.out.println("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"); ...
if (a == null || a.length == 0 || beginIndex < 0 || endIndex > a.length || beginIndex > endIndex) { return new byte[0]; } else { byte[] b = new byte[endIndex - beginIndex]; System.arraycopy(a, beginIndex, b, 0, b.length); return b;
int length = endIndex - beginIndex; byte[] subarray = new byte[length]; System.arraycopy(array, beginIndex, subarray, 0, length); return subarray;
validateOffsetLength(array, array.length, offset, length); byte[] sub = new byte[length]; for (int i = 0; i < length; i++) sub[i] = array[offset + i]; return sub;
Produces a new byte array containing the elements between the start and end indices.
The start index is inclusive, the end index exclusive.
if (array == null) { return null; if (startIndexInclusive < 0) { startIndexInclusive = 0; if (endIndexExclusive > array.length) { endIndexExclusive = array.length; ...
if (array == null) { return null; if (startIndexInclusive < 0) { startIndexInclusive = 0; if (endIndexExclusive > array.length) { endIndexExclusive = array.length; ...
byte[] sub = new byte[length]; for (int i = offset; i < offset + length; i++) sub[i - offset] = b[i]; return sub;
byte[] out = new byte[len]; System.arraycopy(b, ofs, out, 0, len); return out;