how to compare two different objects in java