It seems that the string โA String is an array of charactersโ is too literal. String equals indicates that
Compares this string to the specified object. The result is true if and only if the argument is not null and is a String object that represents the same sequence of characters as this object.
It all depends on the circumstances, but usually you are comparing two objects of the same type or two objects belonging to the same hierarchy (sharing a common superclass).
In this case, a String not char[] , but Java provides mechanisms for moving from one to the other, either by converting String -> char[] with String#toCharArray() or char[] -> String by passing char[] as a parameter to the constructor of String .
This way you can compare both objects after turning String to char[] or vice versa.
Gamb
source share