SuperClassAndInterface
原创
©著作权归作者所有:来自51CTO博客作者虾米大王的原创作品,请联系作者获取转载授权,否则将追究法律责任
package com.shrimpking.t5;
/**
* Created by IntelliJ IDEA.
*
* @Author : Shrimpking
* @create 2024/9/12 16:03
*/
public interface A
{
}
package com.shrimpking.t5;
/**
* Created by IntelliJ IDEA.
*
* @Author : Shrimpking
* @create 2024/9/12 16:03
*/
public interface B
{
}
package com.shrimpking.t5;
/**
* Created by IntelliJ IDEA.
*
* @Author : Shrimpking
* @create 2024/9/12 16:03
*/
public class Base
{
}
package com.shrimpking.t5;
/**
* Created by IntelliJ IDEA.
*
* @Author : Shrimpking
* @create 2024/9/12 16:04
*/
public class Derived extends Base implements A,B
{
}
package com.shrimpking.t5;
/**
* Created by IntelliJ IDEA.
*
* @Author : Shrimpking
* @create 2024/9/12 16:04
*/
public class SuperClassAndInterface
{
public static void main(String[] args)
{
Class clz = Derived.class;
Class baseClz = clz.getSuperclass();
System.out.println("父类:");
System.out.println(baseClz);
System.out.println("实现的接口:");
Class[] interfaces = clz.getInterfaces();
for (Class c : interfaces){
System.out.println(c);
}
}
}