jQuery in Action, 3rd edition
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes can i class be named Object? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "can i class be named Object?" Watch "can i class be named Object?" New topic

can i class be named Object?

Amit Goel
Ranch Hand

Joined: Dec 07, 2000
Posts: 50
hi !!
can a class be named Object ??
class Object {
public static void main(String args[]) {
and be saved as Object.java?

Amit<br /> <br />The Less I have, The more I gain..Off the Beaten Path, I Reign.
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4351

if you are that original of a thinker try it. i want to. I would have to say no though because(if nothing else) your class is in the default package and so is java.lang.* which includes java.lang.Object

Visit my download page
Amit Goel
Ranch Hand

Joined: Dec 07, 2000
Posts: 50
i have tried it and it is working fine like any other class .
then what is the difference between java.lang.Object and this user defined one ?
Angela Poynton
Ranch Hand

Joined: Mar 02, 2000
Posts: 3143
The difference is the package name. You class isn't in the java.lang package. Your class will still extend java.lang.Object though because ultimately every class has to! I think it owuld be very confussing to have another class called Object though.

Pounding at a thick stone wall won't move it, sometimes, you need to step back to see the way around.
I agree. Here's the link: http://aspose.com/file-tools
subject: can i class be named Object?
It's not a secret anymore!