java 實現多重繼承
阿新 • • 發佈:2018-12-26
package com.yangll;
//多重繼承類
public class ClassTestylll extends Person1 {
class inner extends Machine1{
@Override
void run() {
// TODO Auto-generated method stub
System.out.println("Machine1 is run");
}
}
public void run1(){
this.run();
}
public void run2(){
new inner().run();
}
public void run3(ClassTestylll a){
a.run();
}
public void run4(inner b){
b.run();
}
public inner getInner(){
return new inner();
}
public static void main(String[] args){
ClassTestylll t = new ClassTestylll();
t.run1();
t.run2();
t.run3(t);
t.run4(t.getInner());
}
}
class Person1{
public void run(){System.out.println("Persion1 is run");};
}
abstract class Machine1{
abstract void run();
}
//多重繼承類
public class ClassTestylll extends Person1 {
class inner extends Machine1{
@Override
void run() {
// TODO Auto-generated method stub
System.out.println("Machine1 is run");
}
}
public void run1(){
this.run();
}
public void run2(){
new inner().run();
}
public void run3(ClassTestylll a){
a.run();
}
public void run4(inner b){
b.run();
}
public inner getInner(){
return new inner();
}
public static void main(String[] args){
ClassTestylll t = new ClassTestylll();
t.run1();
t.run2();
t.run3(t);
t.run4(t.getInner());
}
}
class Person1{
public void run(){System.out.println("Persion1 is run");};
}
abstract class Machine1{
abstract void run();
}