Here you can find the source of reduceCapacity(Object[] arrays)
public static Object[] reduceCapacity(Object[] arrays)
//package com.java2s; import java.util.Arrays; public class Main { public static Object[] reduceCapacity(Object[] arrays) { if (arrays == null) { return null; }/*from w w w.j a va2 s. c o m*/ int lastIndex = arrays.length - 1; int length = arrays.length; for (int i = lastIndex; i >= 0; i--) { if (arrays[i] == null) { length--; } else { break; } } if (length <= 0) { return null; } return Arrays.copyOf(arrays, length); } }