twc
Posts: 129
Nickname: twc
Registered: Feb, 2004
|
|
Re: How come "extends Object" is not required?
|
Posted: Mar 15, 2004 5:44 AM
|
|
> I'm guessing it's just inherently there but it's worth > asking - When you say something like this... > > class MyClass { ... } > > how come you don't have to say... > > class MyClass extends Object { ... }
Yes, it is inherently there. If you don't explicitly extend a class, then the compiler will treat the code as if it automatically extends the Object class. It is kind of like an exponent on a variable in Algebra. If none is written, the variable is considered to be to the first power.
In a related situation, the import statement for the java.lang package is implicit. You never see import java.lang.*;
because the designers felt that the classes in that package were so vital that every class would need to import that package.
|
|