1
2
3
4
5
6
7
8
|
public
interface
ITest{
public
void
test();
}
public
class
TestImpl
implements
ITest{
public
void
test(){
System.out.println(
"test"
);
}
}
|
1
2
3
|
public
class
OuterClass{
//外部类
private
class
InnerClass{}
//内部类
}
|
1
2
3
4
5
6
|
public
class
Example1 {
public
String getName() {
return
"luffyke"
;
}
}
|
1
2
3
4
5
6
7
|
public
class
Example2 {
public
int
getAge()
{
return
25
;
}
}
|
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
|
public
class
MainExample {
public
class
Test1
extends
Example1 {
public
String getName() {
return
super
.getName();
}
}
public
class
Test2
extends
Example2 {
public
int
getAge() {
return
super
.getAge();
}
}
public
String showName() {
return
new
Test1().getName();
}
public
int
showAge() {
return
new
Test2().getAge();
}
public
static
void
main(String args[]) {
MainExample example =
new
MainExample();
System.out.println(
"姓名:"
+ example.showName());
System.out.println(
"年龄:"
+ example.showAge());
}
}
|