int a=90;
// 创建静态内部类
public static class SInner {
// 内部类中的变量score
int score = 91;
public void show() {
System.out.println("访问外部类中的score:" + HelloWorld.score );
System.out.println("访问内部类中的score:" + score);
System.out.println("访问内部类中的a:" + new HelloWorld().a);
}
}
// 创建静态内部类
public static class SInner {
// 内部类中的变量score
int score = 91;
public void show() {
System.out.println("访问外部类中的score:" + HelloWorld.score );
System.out.println("访问内部类中的score:" + score);
System.out.println("访问内部类中的a:" + new HelloWorld().a);
}
}
2017-04-21
package com.duotai;
public class InitialTraffic {
public static void main(String[] args) {
Traffic t=new Traffic();
t.transport(0);
Traffic p=new Plane();
p.transport(400);
Traffic b=new Bus();
b.transport(40);
Traffic s=new ship();
s.transport(300);
}}
public class InitialTraffic {
public static void main(String[] args) {
Traffic t=new Traffic();
t.transport(0);
Traffic p=new Plane();
p.transport(400);
Traffic b=new Bus();
b.transport(40);
Traffic s=new ship();
s.transport(300);
}}
2017-04-20
package com.duotai;
public class Plane extends Traffic{
public void transport(int num){
System.out.println("飞机的运输方式为在天上飞,能载"+num+"人");
}
}
public class Plane extends Traffic{
public void transport(int num){
System.out.println("飞机的运输方式为在天上飞,能载"+num+"人");
}
}
2017-04-20
package com.duotai;
public class ship extends Traffic{
public void transport(int num){
System.out.println("轮船的运输方式为在海上行,能载"+num+"人");
}
}
public class ship extends Traffic{
public void transport(int num){
System.out.println("轮船的运输方式为在海上行,能载"+num+"人");
}
}
2017-04-20
package com.duotai;
public class Bus extends Traffic{
public void transport(int num){
System.out.println("大巴的运输方式为在陆地跑,能载"+num+"人");
}
}
public class Bus extends Traffic{
public void transport(int num){
System.out.println("大巴的运输方式为在陆地跑,能载"+num+"人");
}
}
2017-04-20