COM defines object identity in terms of pointers to IUnknown interfaces; two objects are the same if their IUnknown interface pointers are equal. A C++ program would need to do some pretty complicated coding to compare COM objects.
// Comparison of two COM objects referenced through
// interfaces c1 and c2
IUnknown *i1, *i2;
c1->QueryInterface(IID_IUnknown, (void **)&i1);
c2->QueryInterface(IID_IUnknown, (void **)&i2);
if (i1 == i2)
printf("It's the same object");
In Java, the equivalent code would look like this:
// Comparison of drawable and printable
if (c1 == c2)
System.out.println("It's the same object");
As you can see, this is the same Java syntax you’d use to compare two object references. Again, Java has hidden many of the complexities of COM programming, making your code more readable and saving you from having to get the little details right.