This tutorial demonstrate how to compare two character array are equal or not. The Arrays.equals(c1, c2) helps to compare it and return boolean value.
import java.util.Arrays; public class Comp2CharArray { public static void main(String[] args) { char[] c1 = new char[] { 'a', 'b', 'c', 'd' }; char[] c2 = new char[] { 'a', 'b', 'c', 'e' }; System.out.println(Arrays.equals(c1, c2)); char[] a1 = new char[] { 'a', 'b', 'c', 'd' }; char[] a2 = new char[] { 'a', 'b', 'c', 'd' }; System.out.println(Arrays.equals(a1, a2)); } }
Download this code
Related Tags for Compare two char array in java: