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