What types of data can be compared?

11.Equality Operators
Why is it wrong to compare String and char when comparing char and int?
System.out.println("aa"=='a'); => error
System.out.println('a'==7); =false
What types of data can be compared? Why?

It’s not good using == to String type.
If you want to compare with String type, you had better use equals method.
I found the same question on another site.
so if you want to ditails, please this site.
maybe it will help you.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.