I understand that == operator checks for equal references(addresses) but I am not getting how the compiler is throwing below error when comparing Thread and String object.
java: incomparable types: java.lang.Thread and java.lang.String
Here is my code:
public static void main(String[] args) {
Thread t = new Thread();
Object o = new Object();
String s = new String("");
System.out.println(t == o);//no issues here
System.out.println(t==s);// but this throws above error
}
Why is it allowing comparison between Thread and Object but not Thread and String?