• Post Reply Bookmark Topic Watch Topic
  • New Topic

What is the Class Definition for a Java class?  RSS feed

 
Korey Hinton
Greenhorn
Posts: 3
Java Objective C Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to know what each of these terms mean relevant to their code structure: Class Definition, Class Declaration, and Class Body.
From the Java tutorial page: Declaring Classes it clearly defines class body and class declaration:

The class body is the code between curly braces.

The class declaration is the modifier, class name and also the class body.

What parts of the code structure would be included in the class definition? Would it be the same thing as the class body?


 
Paul Clapham
Sheriff
Posts: 22823
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Korey Hinton wrote:The class body is the code between curly braces.


So now you know (theoretically) what the class body is. Have a look at some code for existing classes and you'll get a better (i.e. less theoretical) view.

The class declaration is the modifier, class name and also the class body.


So now you know what the class declaration is. Note that our definition here specifically says it's some things plus the class body. You already know what the class body is, so have another look at the code you already looked at and make sure you know how these definitions apply to that code.

What parts of the code structure would be included in the class definition? Would it be the same thing as the class body?


Class definition the same as the class body? Clearly not, since the previous definition specifically says otherwise.

And welcome to the Ranch!
 
Korey Hinton
Greenhorn
Posts: 3
Java Objective C Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul. So are you indicating that class declaration can be considered as the same thing as class definition?
 
Paul Clapham
Sheriff
Posts: 22823
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah. I see I have misread your original post. Sorry about that.

So, you posted definitions for "class body" and "class declaration". And then you brought in an undefined term "class definition" and asked a question about it. But since we're talking about the definitions of things, it's impossible to say anything about things which aren't defined. In other words, "class definition" doesn't mean anything in this context.
 
Korey Hinton
Greenhorn
Posts: 3
Java Objective C Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok this is something I must be remembering from C++. That's why my Google searches about Java weren't returning results.

I found this on Wikipedia's C++ Classes page:
It is common practice to separate the class or structure declaration (called its interface) and the definition (called its implementation) into separate units.


So this term is only used in C++ and doesn't exist in Java.

Thanks for your help Paul!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!