class tombmeret { private static Object resizeArray (Object oldArray, int newSize) { int oldSize = java.lang.reflect.Array.getLength(oldArray); Class elementType = oldArray.getClass().getComponentType(); Object newArray = java.lang.reflect.Array.newInstance( elementType,newSize); int preserveLength = Math.min(oldSize,newSize); if (preserveLength > 0) System.arraycopy (oldArray,0,newArray,0,preserveLength); return newArray; } public static void main(String[] args) { int[] tomb = new int[10]; tomb[0] = 35; tomb[1] = 27; tomb[2] = 42; System.out.println(tomb.length); tomb = (int[]) resizeArray(tomb, 20); System.out.println(tomb.length); } }