me.walkersneps.sneps.utils.check.duplicate.ByteArrayCheck Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of snepsutils Show documentation
Show all versions of snepsutils Show documentation
A compilation of utilities, macros and aliases for common commands
The newest version!
package me.walkersneps.sneps.utils.check.duplicate;
/**
* Created by Walkersneps on 07/05/16
* in package me.walkersneps.sneps.utils.check.duplicate
* for SnepsUtils
*/
/**
* @author Walkersneps
*/
public class ByteArrayCheck {
/**
* Check if an array of byte only contains the same element
*
* @param input the array to analyze
* @return false if the input contains different elements, else true
*/
public static boolean areAllSame(byte[] input) {
//Cover the edge cases that the input array is null or has one element.
if (input.length == 1) {
return true;
}
int compare = input[0]; //Compare to the first element of the input array.
//Check from the second element through the end of the input array.
for (int i = 1; i < input.length; i++) {
if (input[i] != compare) { //if we find a difference:
return false;
}
}
return true;
}
/**
* Always returns true
* @return true
*/
public boolean hello () {
return true;
}
} //end of class
© 2015 - 2024 Weber Informatics LLC | Privacy Policy