能不能调用先不说,单这句就不对,你能编译过去吗?
private int seconpublic Time()

解决方案 »

  1.   

    sorry,我粘错了。
    public class Time
    {
    private int hour;
    private int minute;
    private int second;
    public Time()
    {
    setTime(0,0,0);
    }

    public void setTime(int h,int m,int s)
    {
    hour=((h>=0 && h<24) ? h:0);
    minute=((m>=0 && m<60) ? m:0);
    second=((s>=0 && s<60) ? s:0);
            }
            public String tostring()
            {
             return(hour+":"+minute+":"+second);
            }
    }
    当去调用这个类时,
    import Time;
    public class myTime
    {
    public static void main(String args[])
    {
    Time times=new Time();
    times.setTime(12,23,34);
    System.out.println(times.toString());
    }
    }
    就报错,cannot resolve symbol。我又试了更简单的类,也报错,请大家帮帮忙 
     
      

  2.   

    首先,如果你的类库是按照标准定义的有package的概念,则应该添加到classpath。
    如果没有,则不需要同一个包下(无包概念的友好类)的类。
    其次,你的类最好不要使用java的关键字。
    public class CustomTime {

    private int hour;
    private int minute;
    private int second; 

    public CustomTime() {
    setTime(0,0,0);
    } public void setTime(int h,int m,int s) {
    hour=((h>=0 && h<24) ? h:0);
    minute=((m>=0 && m<60) ? m:0);
    second=((s>=0 && s<60) ? s:0);
    }
        
        public String tostring() {
         return(hour+":"+minute+":"+second);
        }
    }//当去调用这个类时
    public class myTime {
    public static void main(String args[]){
    CustomTime times=new CustomTime();
    times.setTime(12,23,34);
    System.out.println(times.toString());
    }
    }
      

  3.   

    private int seconpublic Time()
    改为
    private int second;public Time()先编译Time在编译myTime
      

  4.   

    我是先编译Time在编译myTime,编译Time,没有报错。
      

  5.   

    你在classpath中设上你的这些类所在的路径就应该可以了。
      

  6.   

    我在环境变量上已设好classpath路径了,依然保错。
      

  7.   

    是吗,那你就再在path中设上路径,然后注销之后再试试看