Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

can we create a class named Object?

 
senthil sen
Ranch Hand
Posts: 184
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can we create a class named Object??
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64173
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happened when you tried it?
bear
 
rob javier
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it compiles
 
Arun Boraiah
Ranch Hand
Posts: 233
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you can create class by name Object. But to create the instance of the Object class written by user and use the same. The class should be refered with fully qualified name. i.e If a user writes Object class in a package test, Then refer the Ojbect class as test.Object
-arun
 
Sam Smoot
Ranch Hand
Posts: 238
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That would be a bit confusing, try naming it somthing else... TestObject, for example...
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's not that confusing. And I think it is a good idea to start using packages early on while learning JAVA.
However, Object is a little vague. I would imagine that your Class file encompusses something a little more defined and less general.
IMHO - Keep very descriptive names for your class files. It makes it easier to know what they do at a glance than to have to go into the code every time. Especially if you haven't looked at it in a while.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic