首页 > 其他分享 >SuperClassAndInterface

SuperClassAndInterface

时间:2024-09-14 14:56:57浏览次数:11  
标签:SuperClassAndInterface Shrimpking shrimpking Author create IDEA public


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);
        }


    }
}

标签:SuperClassAndInterface,Shrimpking,shrimpking,Author,create,IDEA,public
From: https://blog.51cto.com/u_15356972/12016811

相关文章