- class Bd {
- public static void main(String[] args) {
- Person p = new SuperMan();
- p.business();
- SuperMan sm = (SuperMan)p;//向下转型
- sm.fly();
- }
- }
- class Person {
- String name = "jone";
- public void business(){
- System.out.println("谈生意");
- }
- }
- class SuperMan extends Person {
- String name = "superman";
- public void business(){
- System.out.println("谈几个亿");
-
- }
- public void fly(){
- System.out.println("jiuren");
-
- }
- }
复制代码 |
|