Horje
how to compare between to char array java Code Example
how to compare between to char array java
/*
  Compare Two Java char Arrays Example
  This java example shows how to compare two char arrays for equality using
  Arrays.equals method.
*/
 
import java.util.Arrays;
 
public class CompareCharArraysExample {
 
  public static void main(String[] args) {
    //create character arrays
    char[] charArray1 = new char[]{'d','h','r','f'};
    char[] charArray2 = new char[]{'d','h','r','f'};
   
    /*
      To compare two char arrays use,
      static boolean equals(char array1[], char array2[]) method of Arrays class.
     
      It returns true if both arrays are equal. Arrays are considered as equal
      if they contain same elements in same order.
    */
   
    boolean blnResult = Arrays.equals(charArray1,charArray2);
    System.out.println("Are two char arrays equal ? : " + blnResult);
   
    /*
      Please note that two char array references pointing to null are
      considered as equal.
    */
   
  }
}
 
/*
Output of the program would be
Are two char arrays equal ? : true
*/




Java

Related
java program scan folder find files using time Code Example java program scan folder find files using time Code Example
dynamically create textview and add it in linearlayout in recyclerview adapter android Code Example dynamically create textview and add it in linearlayout in recyclerview adapter android Code Example
define nasty Code Example define nasty Code Example
gatewayFilters Code Example gatewayFilters Code Example
minecraft java plugin shift Code Example minecraft java plugin shift Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9