---------- Forwarded message --------- 发件人: Xeno Amess <xenoam...@gmail.com> Date: 2019年6月4日周二 上午12:07 Subject: Re: Is there any reasons for there being 8 ArrayUtil#isEmpty functions? To: dev-subscr...@commons.apache.org <dev-subscr...@commons.apache.org>
and notice that there be only one getLength function in ArrayUtils. public static int getLength(final Object array) { if (array == null) { return 0; } return Array.getLength(array); } Xu Jin <xenoam...@gmail.com> 于2019年6月3日周一 下午11:50写道: > // ---------------------------------------------------------------------- > > */** * **<p>* > > *Checks if an array of Objects is empty or {@code null}. * * @param **array * > > > > *the array to test * @return {@code true} if the array is empty or {@code > null} * @since 2.1 */*public static boolean isEmpty(final Object[] array) { > return *getLength*(array) == 0; > } > > > */** * **<p>* > > *Checks if an array of primitive longs is empty or {@code null}. * * @param > **array * > > > > *the array to test * @return {@code true} if the array is empty or {@code > null} * @since 2.1 */*public static boolean isEmpty(final long[] array) { > return *getLength*(array) == 0; > } > > > */** * **<p>* > > *Checks if an array of primitive ints is empty or {@code null}. * * @param > **array * > > > > *the array to test * @return {@code true} if the array is empty or {@code > null} * @since 2.1 */*public static boolean isEmpty(final int[] array) { > return *getLength*(array) == 0; > } > > > */** * **<p>* > > *Checks if an array of primitive shorts is empty or {@code null}. * * @param > **array * > > > > *the array to test * @return {@code true} if the array is empty or {@code > null} * @since 2.1 */*public static boolean isEmpty(final short[] array) { > return *getLength*(array) == 0; > } > > > */** * **<p>* > > *Checks if an array of primitive chars is empty or {@code null}. * * @param > **array * > > > > *the array to test * @return {@code true} if the array is empty or {@code > null} * @since 2.1 */*public static boolean isEmpty(final char[] array) { > return *getLength*(array) == 0; > } > > > */** * **<p>* > > *Checks if an array of primitive bytes is empty or {@code null}. * * @param > **array * > > > > *the array to test * @return {@code true} if the array is empty or {@code > null} * @since 2.1 */*public static boolean isEmpty(final byte[] array) { > return *getLength*(array) == 0; > } > > > */** * **<p>* > > *Checks if an array of primitive doubles is empty or {@code null}. * * @param > **array * > > > > *the array to test * @return {@code true} if the array is empty or {@code > null} * @since 2.1 */*public static boolean isEmpty(final double[] array) { > return *getLength*(array) == 0; > } > > > */** * **<p>* > > *Checks if an array of primitive floats is empty or {@code null}. * * @param > **array * > > > > *the array to test * @return {@code true} if the array is empty or {@code > null} * @since 2.1 */*public static boolean isEmpty(final float[] array) { > return *getLength*(array) == 0; > } > > > */** * **<p>* > > *Checks if an array of primitive booleans is empty or {@code null}. * * > @param **array * > > > > *the array to test * @return {@code true} if the array is empty or {@code > null} * @since 2.1 */*public static boolean isEmpty(final boolean[] array) { > return *getLength*(array) == 0; > } > > I just don’t understand. > > Why we not using one single function like > > > > public static boolean isEmpty(Object array) { > return *getLength*(array) == 0; > } > > > > ? >