forked from manav88/javaNS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmp.java
More file actions
40 lines (30 loc) · 891 Bytes
/
Emp.java
File metadata and controls
40 lines (30 loc) · 891 Bytes
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
public class Address {
String city, state, country;
Address(String city, String state, String country) {
this.city = city;
this.state = state;
this.country = country;
}
}
public class Emp {
int id;
String name;
Address addres;
Emp(int id, String name, Address addres) {
this.id = id;
this.name = name;
this.addres = addres;
}
void display() {
System.out.println(id + " " + name);
System.out.println(addres.city + " " + addres.state + " " + addres.country);
}
public static void main(String[] args) {
Address address1 = new Address("gzb", "UP", "india");
Address address2 = new Address("gno", "UP", "india");
Emp e = new Emp(111, "varun", address1);
Emp e2 = new Emp(112, "arun", address2);
e.display();
e2.display();
}
}