如何获取父类的父类的类名

cjx0602 2010-06-01 10:34:07
本人新手,多谢指教!!!
rt
...全文
356 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
liyang3233 2010-06-02
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 liyang3233 的回复:]
System.out.println(getClass().getSuperclass().getName());
[/Quote]

System.out.println(getClass().getSuperclass().getSuperclass().getName());
liyang3233 2010-06-02
  • 打赏
  • 举报
回复
System.out.println(getClass().getSuperclass().getName());
任付江 2010-06-02
  • 打赏
  • 举报
回复
getclass().getSuperClass().getSupperClass().getName()
csupanmin 2010-06-02
  • 打赏
  • 举报
回复
getclass().getSuperClass().getSupperClass().getName()
tjb1216 2010-06-02
  • 打赏
  • 举报
回复
谁对谁错,lz试试就知道了,也可查看api文档,应该是Object类里面的方法
paullbm 2010-06-02
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 xiaoye2892 的回复:]
引用 1 楼 redduke1202 的回复:

getClass().getSuperclass().getSuperclass().getName()

perfect
[/Quote]

No perfect!!!



getClass().getSuperclass().getName();
happyfmy 2010-06-02
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 redduke1202 的回复:]

getClass().getSuperclass().getSuperclass().getName()
[/Quote]
perfect
宅男小何 2010-06-01
  • 打赏
  • 举报
回复
t2.getClass().getGenericSuperclass()
kaynezhang 2010-06-01
  • 打赏
  • 举报
回复
java反射

Class c = o.getClass();
//获取接口
Class[] theInterfaces = c.getInterfaces();
for(int i=0; i<theInterfaces.length; i++)
System.out.println(theInterfaces[i].getName());
//获取父类
Class theSuperclass = c.getSuperclass();
「已注销」 2010-06-01
  • 打赏
  • 举报
回复
getClass().getSuperclass().getSuperclass().getName()

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧