• Post Reply Bookmark Topic Watch Topic
  • New Topic

Statement in JLS, clarifications  RSS feed

 
Prathima gaitonde
Ranch Hand
Posts: 130
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
About the default constructor the JLS says "If the class being declared is the primordial class Object, then the default constructor has an empty body.

What does the statement "primordial class Object" mean?
 
Dave Tolls
Ranch Foreman
Posts: 3056
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Object is the base class of all classes in Java.
Hence primordial.
The relevant definition (pulled from Google):
"basic and fundamental"
 
Prathima gaitonde
Ranch Hand
Posts: 130
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Dave, Can you please explain me how to achieve this? I mean an example where in we have default constructor with an empty body.
 
Paul Clapham
Sheriff
Posts: 22819
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The definition you quoted is about the java.lang.Object class. I'm not sure what it is that you want to achieve.
 
Prathima gaitonde
Ranch Hand
Posts: 130
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to declare the class being primordial class object.
 
Paul Clapham
Sheriff
Posts: 22819
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't, because java.lang.Object already exists.

The purpose of the paragraph you read is to provide an exception for the rule "Every constructor of a class must call (in some way) a constructor of its superclass". Since Object doesn't have a superclass, this rule can't apply to it. And you can't create other classes which don't have a superclass.
 
Prathima gaitonde
Ranch Hand
Posts: 130
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank, now answer to my query is clear.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!