-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAggregation.java
More file actions
52 lines (36 loc) · 1.24 KB
/
Copy pathAggregation.java
File metadata and controls
52 lines (36 loc) · 1.24 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
package Misc;
class Address {
static String city;
static String country;
static String state;
public Address(String city, String country, String state) {
Address.city = city;
Address.country = country;
Address.state = state;
}
}
public class Aggregation {
int id;
String name;
Address add; // Aggregation: It contains one more object named address, which contains its
// own informations such as city, state, country, zipcode etc.
public Aggregation(int id, String name, Address add) {
this.id = id;
this.name = name;
this.add = add;
}
void display() {
System.out.println("");
System.out.println("id : " + id);
System.out.println("Name : " + name);
System.out.println("Address : " + Address.city + " " + Address.state + " " + Address.country);
}
public static void main(String[] args) {
Address add1 = new Address("Gurugram", "India", "Haryana");
Address add2 = new Address("Sonipat", "India", "Haryana");
Aggregation Emp1 = new Aggregation(01, "Vivek", add1);
Aggregation Emp2 = new Aggregation(02, "Amit", add2);
Emp1.display();
Emp2.display();
}
}