62,615
社区成员
发帖
与我相关
我的任务
分享
package com.cn;
import com.dai.C;
public class A {
public void b() {
System.out.println("A.b");
}
protected void c() {
System.out.println("A.c");
}
private void d() {
System.out.println("A.d");
}
public static void main(String[] args) {
A c = new C();
c.d();//打印出A.d了呵呵??
}
}
/*
* private类型的能继承吗?呵呵
*
* */
package com.cn;
import java.lang.reflect.Method;
public class C extends A{
public static void main(String[] args) {
A c = new C();
Class<? extends A> type = c.getClass();
Method[] methods = type.getMethods();
for(Method me:methods) {
System.out.println(me.getName());
}
}
}
/*
最后的输出为:
main
b
wait
wait
wait
equals
toString
hashCode
getClass
notify
notifyAll
为什么没有c呢?
*/