Java Array class equals(byte[] a, byte[] a2) example
Array class equals(byte[] a, byte[] a2)method example
Array class equals(byte[] a, byte[] a2) method example. This example shows you how to use equals(byte[] a, byte[] a2) method.This method Returns true if the two specified arrays of bytes are equal to one another.
Here is the code:-
/**
* @Program that Returns true if the two specified arrays of bytes are equal
* to one another.
* equal to one another.
* equals2Array.java
* Author:-RoseIndia Team
* Date:-15-May-2008
*/
import java.util.*;
public class equals2Array {
public static void main(String[] args) {
//creating an byte array
byte o[]={1,2,3,4,5,6,7};
//byte o[]={1,2,3,4,5,6,7,8};
byte o1[]={1,2,3,4,5,6,7};
//Returns true if both of array declared are equal
boolean b=Arrays.equals(o, o1);
System.out.println("Two specified arrays of byte are equal:-"+b);
}
} |
Output of the program:-
| Two specified arrays of byte are equal:-true |
|