In java reference accessibility is not allowed but you can get the address in encrypted form using hashcode() function. If you want to compare two objects you have the hashcode that you can compare and say whether it is same or not.