Java: Rationale of the Object class not being declared abstract

后端 未结 10 1097
粉色の甜心
粉色の甜心 2020-12-06 04:54

Why wasn\'t the java.lang.Object class declared to be abstract ?

Surely for an Object to be useful it needs added state or behaviour, an Object class is

10条回答
  •  南笙
    南笙 (楼主)
    2020-12-06 05:11

    I am not sure this is the reason, but it allows (or allowed, as there are now better ways of doing it) for an Object to be used as a lock:

    Object lock = new Object();
    
    ....
    
    
    synchronized(lock)
    {
    }
    

提交回复
热议问题