Casting in equals method

前端 未结 7 1396
攒了一身酷
攒了一身酷 2020-12-31 09:46

I have a question about overriding the equals method in Java. In my book, I have the following example:

public class Dog{
     private String na         


        
7条回答
  •  北海茫月
    2020-12-31 10:15

    For JVM it is not that obvious that obj is Dog, so you have to be explicit with the cast.

提交回复
热议问题