比如
interface ainter{ 
void dosth(int i); 
} class aclass implements ainter 

public void dosth(int i) { 
//......

} class bclass implements ainter 

public void dosth(int i) { 
//......


如何在其他位置调用函数dosth
比如
import ...ainter; 
//不能写import ......aclass下面怎么写才能调用aclass的dosth函数?

解决方案 »

  1.   

    不能import?用工厂模式返回一个aclass的实例
      

  2.   

    aclass testa = new aclass ();

    testa.dosth(1);

    aclass  testb = new aclass ();

    testb.dosth(1);
      

  3.   

    用函数来实现啦,
    interface a{}
    class aa implement a{}
    function a b{
    aa s=new aa();
    return s;
    }
    这样就得到一个aa类的实例
      

  4.   

    aclass testa = new aclass ();

    testa.dosth(1);

    bclass  testb = new bclass ();

    testb.dosth(1);是不是想这样
      

  5.   

    to aqy_19781228(一声叹息)
    aclass 这个类没有import,应该不认识吧
      

  6.   

    我看到的是这个import **.**.**.ainter; 
    ainter a_test=nteractionObjectFactory.getInstance().getInteractionObject(ainter.class);
    a_test.dosth(2);为什么调用的是aclass而不是bclass?
      

  7.   

    因为继续向内看那个jar包里的东西很吃力,我想问的是代入参数就是接口类名,怎么知道是哪个实现类的?