Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
jerry - Common Java Functionality Copyright (c) 2012-2015, Sandeep Gupta http://sangupta.com/projects/jerry Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
  
 package com.sangupta.jerry.util;

Author(s):
sangupta
 
 public class EqualUtils {

Tests if two byte arrays are equal in content or not.

Parameters:
array1 the first array
array2 the second array
Returns:
true if arrays are equal in object or content, false otherwise
 
 	public static boolean equals(byte[] array1byte[] array2) {
 		if(array1 == null || array2 == null) {
 			return false;
 		}
 		
 		if(array1 == array2) {
 			return true;
 		}
 		
 		if(array1.length != array2.length) {
 			return false;
 		}
 		
 		for(int index = 0; index < array1.lengthindex++) {
 			if(array1[index] != array2[index]) {
 				return false;
 			}
 		}
 		
 		return true;
 	}

Tests if two char arrays are equal in content or not.

Parameters:
array1 the first array
array2 the second array
Returns:
true if arrays are equal in object or content, false otherwise
 
 	public static boolean equals(char[] array1char[] array2) {
 		if(array1 == null || array2 == null) {
 			return false;
 		}
 		
 		if(array1 == array2) {
 			return true;
 		}
 		
 		if(array1.length != array2.length) {
 			return false;
 		}
 		
 		for(int index = 0; index < array1.lengthindex++) {
 			if(array1[index] != array2[index]) {
 				return false;
 			}
 		}
 		
 		return true;
 	}

Tests if two short arrays are equal in content or not.

Parameters:
array1 the first array
array2 the second array
Returns:
true if arrays are equal in object or content, false otherwise
	public static boolean equals(short[] array1short[] array2) {
		if(array1 == null || array2 == null) {
			return false;
		}
		if(array1 == array2) {
			return true;
		}
		if(array1.length != array2.length) {
			return false;
		}
		for(int index = 0; index < array1.lengthindex++) {
			if(array1[index] != array2[index]) {
				return false;
			}
		}
		return true;
	}

Tests if two int arrays are equal in content or not.

Parameters:
array1 the first array
array2 the second array
Returns:
true if arrays are equal in object or content, false otherwise
	public static boolean equals(int[] array1int[] array2) {
		if(array1 == null || array2 == null) {
			return false;
		}
		if(array1 == array2) {
			return true;
		}
		if(array1.length != array2.length) {
			return false;
		}
		for(int index = 0; index < array1.lengthindex++) {
			if(array1[index] != array2[index]) {
				return false;
			}
		}
		return true;
	}

Tests if two long arrays are equal in content or not.

Parameters:
array1 the first array
array2 the second array
Returns:
true if arrays are equal in object or content, false otherwise
	public static boolean equals(long[] array1long[] array2) {
		if(array1 == null || array2 == null) {
			return false;
		}
		if(array1 == array2) {
			return true;
		}
		if(array1.length != array2.length) {
			return false;
		}
		for(int index = 0; index < array1.lengthindex++) {
			if(array1[index] != array2[index]) {
				return false;
			}
		}
		return true;
	}

Tests if two float arrays are equal in content or not.

Parameters:
array1 the first array
array2 the second array
Returns:
true if arrays are equal in object or content, false otherwise
	public static boolean equals(float[] array1float[] array2) {
		if(array1 == null || array2 == null) {
			return false;
		}
		if(array1 == array2) {
			return true;
		}
		if(array1.length != array2.length) {
			return false;
		}
		for(int index = 0; index < array1.lengthindex++) {
			if(array1[index] != array2[index]) {
				return false;
			}
		}
		return true;
	}

Tests if two double arrays are equal in content or not.

Parameters:
array1 the first array
array2 the second array
Returns:
true if arrays are equal in object or content, false otherwise
	public static boolean equals(double[] array1double[] array2) {
		if(array1 == null || array2 == null) {
			return false;
		}
		if(array1 == array2) {
			return true;
		}
		if(array1.length != array2.length) {
			return false;
		}
		for(int index = 0; index < array1.lengthindex++) {
			if(array1[index] != array2[index]) {
				return false;
			}
		}
		return true;
	}

Test if two byte arrays are not equal in all respects.

Parameters:
bytes1 the first byte array
bytes2 the second byte array
Returns:
true if arrays are not equal, false otherwise
	public static boolean notEquals(byte[] bytes1byte[] bytes2) {
		return !equals(bytes1bytes2);
	}
New to GrepCode? Check out our FAQ X