Java tutorial
//package com.java2s; import java.lang.reflect.*; public class Main { /** * Resizes an array of Objects to a specified size. * * @param list Array to be resized. * @param newSize Array size after resizing * @return Array of type Object with the specified size */ static public Object resizeArray(Object[] list, int newSize) { Class type = list.getClass().getComponentType(); Object temp = Array.newInstance(type, newSize); System.arraycopy(list, 0, temp, 0, Math.min(Array.getLength(list), newSize)); return temp; } static public long[] resizeArray(long[] f, int newSize) { long[] newf = new long[newSize]; System.arraycopy(f, 0, newf, 0, Math.min(f.length, newSize)); return newf; } public static float min(float[] f) { float min = Float.MAX_VALUE; for (float ff : f) if (ff < min) min = ff; return min; } }