what is containership in java | composition in java |

Опубликовано: 16 Ноябрь 2023
на канале: LearningPointAabid
118
12

Containership in Java is a relationship between classes where one class (the container) contains an object of another class (the contained). This relationship is also known as "has-a" relationship.
Has-a relationships can be used to represent a variety of real-world relationships, such as:
A person has a car.
A company has employees.
A house has a kitchen.

For example, a Car class could contain an Engine object. The Car class would be the container class, and the Engine class would be the contained class. This relationship would allow the Car class to access the methods and properties of the Engine class.

Containership lets a class obtain objects of another class as member data. Like class A can obtain an object of class B ,e.g b1 as member. So here class A becomes container class and class B becomes contained class.
containership does not have such modes as - public, private, protected .
properties of contained object can not be modified.
Containership is some kind of has-a relationship( e . g Class A has an object of class B as it’s member)
Containership is the ability of a class to contain objects of different classes as member data
But if a class is contained in another, the container does not get the ability to change or add behavior to the contained

Containership is used in Java to create complex data structures out of simpler ones. It also allows for code reuse and modularity.
source code link :-
previous code link :-


На этой странице сайта вы можете посмотреть видео онлайн what is containership in java | composition in java | длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь LearningPointAabid 16 Ноябрь 2023, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 118 раз и оно понравилось 12 зрителям. Приятного просмотра!