就是比如类A继承了类B,在类B中导入的那些包,如果在类A中也需要,是否还要重新导入?

解决方案 »

  1.   

    你在eclipse中试试不就知道了吗? 
      

  2.   

    Father 类: 
    package pone;import java.util.HashMap;
    public class Father { HashMap<String,String> ha = new HashMap<String,String>();


    }
    子类:package pone;public class Son extends Father {


      public  static void main(String[] args){
      
      
      Father  th =  new Son();
      
      th.ha.put("tt", "test is good!");
      
      System.out.println(th.ha.get("tt"));
      
      }


    }------父类用了引入了 HashMap,子类中不需要引入,子类程序照样使用 HashMap!  
      

  3.   


    不知道是你没看清他的问题还是我没有看清!
    二楼这个th.ha.put("tt", "test is good!")是调用父类的对象;
    楼主问的是不是在子类中再声名一个HashMap是否需要导入java.util.HashMap;如果是这样的话,是需要导入包的。
      

  4.   

    二楼这个th.ha.put("tt", "test is good!")是调用父类的对象;
    估计不是楼问的问题,也可能没理解楼主的意思吧!??
    楼主问的应该是在子类中再声名一个HashMap是否需要导入java.util.HashMap;如果是这样的话,是需要导入包的。