java why should equals method input parameter be Object

后端 未结 6 938
别那么骄傲
别那么骄傲 2020-12-09 10:42

I\'m going through a book on data structures. Currently I\'m on graphs, and the below code is for the vertex part of the graph.

class Vertex{
    /         


        
6条回答
  •  余生分开走
    2020-12-09 11:13

    It is because the author is overriding equals. Equals is specified in java.lang.Object and is something that all classes inherrits from.

    See the javadoc for java.lang.Object

提交回复
热议问题