2022-08-22 20:18来源:m.sf1369.com作者:宇宇
package pack1;
public class A {
private int i;
float f;
public double d;
}
package pack1;
public class B {
public static void main(String args[]){
A a=new A();
a.f=2;
a.d=3;
}
}
package pack2;
public class B {
public void f(){
System.out.println(执行pack2包中的类B的方法f);
}
}
package pack2;
import pack1.A;
public class C {
public static void main(String args[]){
A a=new A();
B b=new B();
b.f();
a.d=3;
}
}
interface CanFly{
public void fly();}
class Plane implements CanFly{
public void fly(){
System.out.println(Plane fly);
}
}
class Bird implements CanFly{
public void fly(){
System.out.println(Bird fly);
}
}
public class Test{
public static void main(String[] args){
Plane p = new Plane();
Bird b = new Bird();
new Test().makeFly(p,b);
}
void makeFly(Plane p,Bird b){
p.fly();
b.fly();
}
}