• Post Reply Bookmark Topic Watch Topic
  • New Topic

Composition in java  RSS feed

 
Joy Vergis
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
i am a new bee to java. I have a doubt on composition. For defining composition is it that the included class should be defined as a private static member only.

Example:




Please help.

Thanks,
 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, there's no need for it to be a nested or inner class (though it could be). The usual arrangement would be that the included class is a separate class, and the owning class has a private reference (or references) to an instance of it. Something like this:
In that example, each University can have several Departments.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
look at good explanation from Stephan . just want to share this
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!