| 3698 | } |
| 3699 | |
| 3700 | public static <T> T[] copyOf(T[] original, int newLength, Class<? extends T[]> newType) { |
| 3701 | if (newLength < 0) { |
| 3702 | throw new NegativeArraySizeException("copyOf expects newLength >= 0, but found "+newLength); |
| 3703 | } |
| 3704 | T[] arr = (T[])Array.newInstance(newType.getComponentType(), newLength); |
| 3705 | int len = Math.min(original.length, newLength); |
| 3706 | System.arraycopy(original, 0, arr, 0, len); |
| 3707 | return arr; |
| 3708 | } |
| 3709 | |
| 3710 | public static <T> T[] copyOf(T[] original, int newLength) { |
| 3711 | if (newLength < 0) { |