-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPercel1.java
More file actions
37 lines (33 loc) · 813 Bytes
/
Copy pathPercel1.java
File metadata and controls
37 lines (33 loc) · 813 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
/**
* 内部类
*/
/**
* 最普通的内部类使用方法
* 仅仅是使用内部类作为封装对象和方法,简化代码以及模块化代码
*/
public class Percel1 {
class content{
private int i=11;
public int value() {
return i;
}
}
class Destination{
private String lable;
Destination(String whereto) {
lable = whereto;
}
String readLable() {
return lable;
}
}
public void ship(String dest) {
content content = new content();
Destination destination = new Destination(dest);
System.out.println(destination.readLable());
}
public static void main(String[] args) {
Percel1 percel1 = new Percel1();
percel1.ship("aaa");
}
}