Does the comparison operator also compares data types...
the following program gives the output Equals..Please advise...

class Check{
     public static void main(String[] args){
         int numA=100;
         double numA=100;
         if(numA==numB)  System.out.println("Equals");
         else System.out.println("Not Equal");
     }
}

no, it only compares memory locations.
So if 2 references point to the same object in memory it will return true (in which case they obviously point to the same type object as well), if they point to 2 different objects it will return false even if equals returns true for those 2 objects (and remember that equals may return true if objects are of different types depending on how it's implemented).

thanx 4 da explaination....i got the idea.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.