-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmployeeOuter.java
More file actions
44 lines (36 loc) · 1.03 KB
/
EmployeeOuter.java
File metadata and controls
44 lines (36 loc) · 1.03 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
package innerclass;
public class EmployeeOuter {
private int id;
private String name;
public EmployeeOuter(int id, String name) {
this.id = id;
this.name = name;
}
public static void main(String[] args) {
EmployeeOuter employee = new EmployeeOuter(100, "Bill Gate");
AddressInner address = employee.new AddressInner("New York City", "New York", "00501", "USA");
address.showProperties();
}
private class AddressInner {
private String city;
private String state;
private String zip;
private String country;
public AddressInner(String city, String state, String zip, String country) {
this.city = city;
this.state = state;
this.zip = zip;
this.country = country;
}
private void showProperties() {
// Inner class can access outer class all data members including
// private.
System.out.println(id);
System.out.println(name);
System.out.println(city);
System.out.println(state);
System.out.println(zip);
System.out.println(country);
}
}
}