- 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);Useful while comparing the received password with the stored one. Since password should not be stored in String (String is immutable, So the password will be there in RAM as a non reference value, which is easy to access). So its better approach to use the char array.