Java Tutorial 14 : Aggregation in Java | With Real Life Example -YouTube

Опубликовано: 26 Июль 2026
на канале: Technical Suneja
17,394
371

Java Tutorial 14 : Aggregation in Java | With Real Life Example -YouTube

Aggregation in Java

If a class have an entity reference,
it is known as Aggregation.
Aggregation represents HAS-A relationship.

Consider a situation, Employee object contains many
informations such as id, name, emailId etc.
It contains one more object named address,
which contains its own informations such as city, state,
country, zipcode etc. as given below.

class Employee{
int id;
String name;
Address address;//Address is a class
...
}

In such case, Employee has an entity reference address,
so relationship is Employee HAS-A address.

Why use Aggregation?

For Code Reusability.


When use Aggregation?

Code reuse is also best achieved by aggregation when
there is no is-a relationship.
Inheritance should be used only
if the relationship is-a is maintained throughout
the lifetime of the objects involved; otherwise,
aggregation is the best choice.

Subscribe Youtube Channel :    / tutorialspoint2016  

Like FaceBook Page :   / tutorialspoint2016  

Learn New ??

Visit Our Channel : (Playlists)
   / @technicalsuneja  

1) Learn Bootstrap :    • Bootstrap 3 Tutorial 1 - What Is Bootstrap  

2) PHP Tutorial for Beginners (For Absolute Beginners) :    • PHP Tutorial for Beginners 1 # Getting Sta...  

3) AngularJS Tutorial for Beginners :    • AngularJS Tutorial for Beginners - 1 - Int...  

4) Java Tutorial For Beginners (Step by Step tutorial) :    • Java Tutorial For Beginners 1 - About Java...  

5) Whats new in PHP 7 in Hindi :    • Whats new in PHP 7 | (Introduction) | Part-1  

6) Build a PHP MVC Application :    • Build a PHP MVC Application: Introduction ...  

7) CRUD with PHP and MySQLi Tutorial 2017 :    • PHP Tutorials: How To CRUD with PHP and My...  

8) PDO-OOP-PHP-CRUD-with-Bootstrap 2017 :    • PDO-OOP-PHP-CRUD-with-Bootstrap 2016 (Conn...  

9) Magic Methods in PHP Tutorial :    • Magic Methods in PHP (Introduction)  | Part-1  

10) OOPS Tutorial for Beginners in PHP :    • OOPS concepts in PHP Objects & Classes  Pa...  

11) Technology Tips and Tricks :    • Video  

If you have any doubt regarding this stuff than you can leave your comment in comment box.

Twitter id :  / tutorialspoint2  

facebook :   / tutorialspoint2016  

Instragram :   / tutorialspoint2016  

Google plus : https://plus.google.com/+TutorialsPoi...

Blogger : http://tutorialspoint2016.blogspot.in/

Don't forget to hit the Subscribe & Like button!