Here you can find the source of allEqual(int[] values)
Parameter | Description |
---|---|
values | the array |
public static boolean allEqual(int[] values)
//package com.java2s; //License from project: Open Source License public class Main { /**/*from ww w.j ava2s .co m*/ * Checks if elements in the given array are all equal. * @param values the array * @return true if all elements in the given array are equal */ public static boolean allEqual(int[] values) { if (values.length == 0) { return true; } int value = values[0]; for (int i = 1; i < values.length; i++) { if (values[i] != value) { return false; } } return true; } /** * Checks if elements in the given array are all equal. * @param values the array * @return true if all elements in the given array are equal */ public static boolean allEqual(double[] values) { if (values.length == 0) { return true; } double value = values[0]; for (int i = 1; i < values.length; i++) { if (values[i] != value) { return false; } } return true; } /** * Checks if elements in the given array are all equal. * @param values the array * @return true if all elements in the given array are equal */ public static boolean allEqual(boolean[] values) { if (values.length == 0) { return true; } boolean value = values[0]; for (int i = 1; i < values.length; i++) { if (values[i] != value) { return false; } } return true; } }