同一个包里面可以 import Comment;
也可以不写,直接用

解决方案 »

  1.   

    不要写引用语句,
    然后只要保证这两个文件编译称的class文件在CLASSPATH设置的路径之内,
    这样就确保它们互相能够找到并且加载。
      

  2.   

    楼主的意思是不是
    class Comment{
    .............
    }class Reserved{
       private Comment comment;
       ......
    }comment = new Comment();或者类似Constructor的就可以了,
    private Comment comment的意思是在Reserved里comment是private的,而不是Comment是private的。Comment的访问控制是在Comment里定义的。
      

  3.   

    用classpath
    个人感觉不太好
    再说我也不知道楼主在说啥
      

  4.   

    package ch12;
      import java.lang.* ;
      import java.sql.* ;
      import java.util.* ;
      import javax.servlet.* ;  public class ConnPool{
        private static final int defaultMaxConnections=3 ;      private Vector  freeConnections ;
        private Hashtable  boundConnections ;
        private String  driverName ;
        private String  jdbcURL ;
        private String  username ;
        private String  password ;
        private int maxConnections ;
        
    // ------------------------------------ Constructot -------------------------------------
        public ConnPool( int numConnections ) {
          maxConnections=numConnections ;
          boundConnections=null ;
          freeConnections=null ;
          driverName="" ;
          jdbcURL="" ;
          username="" ;
          password="" ;
        }// --------------------------------------------------------------------------------------
        public ConnPool() {
          this( defaultMaxConnections ) ;
        }    }
        package ch12;  import java.lang.* ;
      import java.sql.* ;
      import javax.servlet.*;
      
            
      public class SQLProxy{
     ********   private ConnPool  connPool ;
        private Connection  conn ;
        private ResultSet  rs ;
        private ResultSetMetaData  rsmd ;
        private Statement  stmt ;
        private String  driverName ;
        private String  jdbcURL ;
        private String  username ;
        private String  password ;// -------------------------------------- Constructor --------------------------------------
        public SQLProxy() {
          connPool=null ;
          conn=null ;
          rs=null ;
          rsmd=null ;
          stmt=null ;
        }}  不管怎么样?还是谢谢大家!我的导师让我写一个扩展的来融合这2个问题,我还是不明白,按理说你们说的应该没问题。或许是我的编译什么出了问题。
      

  5.   

    package ch12;
      import java.lang.* ;
      import java.sql.* ;
      import java.util.* ;
      import javax.servlet.* ;  public class Comment{
        private static final int defaultMaxConnections=3 ;      private Vector  freeConnections ;
        private Hashtable  boundConnections ;
        private String  driverName ;
        private String  jdbcURL ;
        private String  username ;
        private String  password ;
        private int maxConnections ;
        
    // ------------------------------------ Constructot -------------------------------------
        public Comment( int numConnections ) {
          maxConnections=numConnections ;
          boundConnections=null ;
          freeConnections=null ;
          driverName="" ;
          jdbcURL="" ;
          username="" ;
          password="" ;
        }// --------------------------------------------------------------------------------------
        public Comment() {
          this( defaultMaxConnections ) ;
        }    }
        package ch12;  import java.lang.* ;
      import java.sql.* ;
      import javax.servlet.*;
      
            
      public class Reserved{
     ********   private Comment  comment ;
        private Connection  conn ;
        private ResultSet  rs ;
        private ResultSetMetaData  rsmd ;
        private Statement  stmt ;
        private String  driverName ;
        private String  jdbcURL ;
        private String  username ;
        private String  password ;// -------------------------------------- Constructor --------------------------------------
        public Reserved() {
          comment=null ;
          conn=null ;
          rs=null ;
          rsmd=null ;
          stmt=null ;
        }}  不管怎么样?还是谢谢大家!我的导师让我写一个扩展的来融合这2个问题,我还是不明白,按理说你们说的应该没问题。或许是我的编译什么出了问题。
      

  6.   

    直接用的时候private Comment comment出现错误,在plusedit里也没有显示已经定义过的颜色,别的是有颜色的。