An object is a real-world entity like a pen, table, book and many more. Here an Object-Oriented Programming is a paradigm or methodology for designing the applications using the objects and classes.

OOPS simplifies all the software developments using the OOPs Principles. In this tutorials, we are going to understand what is an association and where it is used.

What is Association:

Association establishes a relationship between any two objects. It can be defined as the multiplicity between the objects.

Hence you must know about the relationships between two objects, like one-to-one, many-to-one, one-to-many and many-to-many as all these are the association between objects.

Association also has its special form with Aggregation and Composition is the special form of aggregation.

For Example, Organization and Employee have an association.



import java.util.ArrayList;
import java.util.List;

public class AssociationDemo {
    public static void main(String[] args) {
        Organization organization = new Organization();
        Employee employee = new Employee();
        Employee employee2 = new Employee();
        List<Employee> empList = new ArrayList();
        System.out.println(organization.getEmployees()+" are Employees of "+
class Organization {
    private String organizationName;
    List<Employee> employees;
    public String getOrganizationName() {
        return organizationName;
    public void setOrganizationName(String organizationName) {
        this.organizationName = organizationName;

    public List<Employee> getEmployees() {
        return employees;

    public void setEmployees(List<Employee> employees) {
        this.employees = employees;
class Employee {
    private String employeeName;
    public String getEmployeeName() {
        return employeeName;
    public void setEmployeeName(String employeeName) {
        this.employeeName = employeeName;

    public String toString() {
        return employeeName;


[Rahul, Chandra] are Employees of Google

In the above example, one Organization has many numbers of Employees. Therefore the relationship between the Organization and Employee is one-many. And also those two are two different entities. Therefore the relationship between the two entities is called association.

Happy Learning 🙂

One Comment

  1. md mouvin June 30, 2020 at 8:24 am - Reply


Leave A Comment