Compare Two char Arrays - Java Language Basics

Java examples for Language Basics:char

Description

Compare Two char Arrays

Demo Code

 
import java.util.Arrays;
 
public class Main {
 
  public static void main(String[] args) {
    char[] charArray1 = new char[]{'d','h','r','q'};
    char[] charArray2 = new char[]{'d','a','w','f'};
   /*from w  ww. ja  v a 2s  .  c om*/
    boolean blnResult = Arrays.equals(charArray1,charArray2);
    System.out.println("Are two char arrays equal ? : " + blnResult);
  }
}

Result


Related Tutorials