如题:我现在有一个接口
A
针对A有三个实现类A1Impl,A2Impl,A3Impl
我想在运行时通过A获得
A1Impl,A2Impl,A3Impl的类型集合。
请问有办法吗?我觉得应该可以,
eclipse编辑器里都可以查看接口的所有实现类。
这个理论上和那个是一样的。帮帮忙

解决方案 »

  1.   

    用这个关键字 
     A instanceof A1Impl 
     A instanceof A2Impl 
     A instanceof A3Impl 
    测试下看可以吗?
      

  2.   

    不知道反射能不能做到
    我查了一下API 好像没有提供 这样的方法啊。
    实现不行就自己写一个方法算了  用instanceof 检测
      

  3.   

    其实我是想实现下面的功能public interface Action {
    public void execute();
    }@Controller
    public IndexAction implement Action {
    public void execute(){
    return null;
    }
    }
    @Controller
    public ListAction implement Action {
    public void execute(){
    return null;
    }
    }假如在系统中有很多这样的Action的实现类。我要怎样做才能通过Action收集到
    所有实习了这个接口的类的信息呢?目的就是想用java的注释来代替XML文件