public class Person { private String firstName; private String lastName; private Address address; //Composition example public Person() { address = new Address(); } public Address getAddress() { return address; } }
Employee Class public class Employee { private String firstName; private String lastName; private int age; //Aggregation Java example private Address address; public void setAddress(Address address) { this.address = address; } public Address getAddress() { return address; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)