-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAggregationExamples.java
39 lines (35 loc) · 1.11 KB
/
AggregationExamples.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package Examples;
// Taking Address & Student as an Example
class Address {
int StreetNo;
String City;
String State;
String Country;
Address(int StreetNo, String City, String State, String Country){
this.StreetNo = StreetNo;
this.City = City;
this.State = State;
this.Country = Country;
}
}
class Student {
int Rollno;
String StudentName;
Address StudentAddress;
Student(int Rollno, String StudentName, Address StudentAddress){
this.Rollno = Rollno;
this.StudentName = StudentName;
this.StudentAddress = StudentAddress;
}
}
public class AggregationExamples {
public static void main(String[] args) {
Address address = new Address(34, "New York", "NYC", "USA");
Student student = new Student(8, "Mubassim", address);
System.out.println(student.StudentName);
System.out.println(student.StudentAddress.City);
System.out.println(student.StudentAddress.Country);
System.out.println(student.StudentAddress.State);
System.out.println(student.StudentAddress.StreetNo);
}
}