Obviously, the above test will evaluate to false. But it will compile.

This is legal because the type system says that charscould be a String. Note that CharSequence is a supertype of String and StringBuffer. (In this case, the supertype is an interface, but it doesn't need to be an interface.)

Email codedump link for Java == operator works for list and set comparison but gives compile time error for String and StringBuilder comparison