I have been programming in Java for quite some time, but when I tried to explain what an java.lang.Object
class is to a friend, I could not come up with more than a simple one-liner:
All objects in Java extend java.lang.Object
implicitly
I was not quite sure why it should do so.
So, I looked upon the source code on GrepCode, hoping that I can find some clues. Now I know what a java.lang.Object
is and what it does, I want to know if there was any specific reason as to why it was designed this way.
My question still prevails: why should every object extend java.lang.Object
?
question from:
https://stackoverflow.com/questions/19114997/why-does-every-object-in-java-implicitly-extend-java-lang-object-class 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…