Skip to content

Instantly share code, notes, and snippets.

@czxttkl
Created October 15, 2014 16:06
Show Gist options
  • Save czxttkl/990b61b41eed4085f649 to your computer and use it in GitHub Desktop.
Save czxttkl/990b61b41eed4085f649 to your computer and use it in GitHub Desktop.
@SuppressWarnings("unchecked")
public static <T> T[] concatArrays8(T[] arr1, T[] arr2) {
T[] both = (T[])Array.newInstance(arr1.getClass().getComponentType(), arr1.length+arr2.length);
Object[] bothObj = Stream.concat(Arrays.stream(arr1), Arrays.stream(arr2)).toArray();
for (int i = 0; i < both.length; i++) {
both[i] = (T)bothObj[i];
}
return both;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment