Get your CodeRanch badge!*
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "can i class be named Object?" Watch "can i class be named Object?" New topic
Author

can i class be named Object?

Amit Goel
Ranch Hand

Joined: Dec 07, 2000
Posts: 50
hi !!
can a class be named Object ??
like:
class Object {
public static void main(String args[]) {
System.out.println("hello");
}
}
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: 4339
    
    2

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


SCJP
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?
 
Similar Threads
anonymous classes
beginner question: cannot find symbol compiler error
can we create a class named Object?
question regarding constructors
how to get object of compiler class