日期:2014-05-20 浏览次数:20903 次
public class test5 {
public static void main(String[] args) {
// c2.c2_func1();
c2.c2_func2(new c2());
}
}
interface I1 {
void I1_func1();
}
class c2 implements I1{
public void I1_func1() {System.out.println("I1_func1()");}
// static void c2_func1() {I1_func1();} /* complier error */
static void c2_func2(I1 o) {o.I1_func1();} /* pass! */
}
static void c2_func1() {I1_func1();} /* complier error */
------解决方案--------------------
注意:static方法内是可以调用非static方法的
static方法调用非static方法的前提条件是需要对象引用的