Yes we can use any class as a map key in java,suppose we have a class name named MyMap so here is some description of MaMap class
See this example:
//MyKey name argument passed is used for equals() and hashCode()
MyKey key = new MyKey('Shivam Pandey'); //assume hashCode=1234
// Below code will change the key hashCode() and equals()
// but it's location is not changed.
key.setName('ShashiKant'); //assume new hashCode=7890
//below will return null, because HashMap will try to look for key
//in the same index as it was stored but since key is mutated,
//there will be no match and it will return null.
myHashMap.get(new MyKey('Shivam Pandey'));