UnderStanding Compostion(Please tell me if i understand the concept correctly)
I am a newbie at Java, and I have been following thenewboston Java tutorials on youtube. And Bucky introduced me to a concept called Composition. Basically composition allows you to turn a class into an object. This is beneficial because you don't have to make any changes to your main class. It other words, I can create a brand new class and create an object that references another class.
Please correct me if I am wrong. I am trying to build a solid base.
Re: UnderStanding Compostion(Please tell me if i understand the concept correctly)
Quote:
Basically composition allows you to turn a class into an object.
Composition refers to creating classes composed of other classes - it is often contrasted with inheritance (for instance, 'Composotion over Inheritance'). For creating objects from classes, see
Lesson: Classes and Objects (The Java™ Tutorials > Learning the Java Language)
Creating Objects
Inheritance (The Java™ Tutorials > Learning the Java Language > Interfaces and Inheritance)
Re: UnderStanding Compostion(Please tell me if i understand the concept correctly)
I kind of thought it was connecting classes to another class.