呵呵!!!value哪来的?Double类里可没有这个变量!

解决方案 »

  1.   

    //anotherDouble.value
     私有的,不能访问//double thisVal = value;这个value是哪儿来的?
      

  2.   

    1。public interface Comparable{
    public int compareTo(Object o);
    }
    2。public class Double implements Comparable{

    public int compareTo(Object o){

        anotherDouble = (Double)o;
        double anotherVal =anotherDouble.value;
                 double thisVal = anotherVal;
    return 0;
    }  
    }
      

  3.   

    1。public interface Comparable{
    public int compareTo(Object o);
    }
    2。public class Double implements Comparable{
         private double value;
         public void setValue(double value){
    this.value = value;}
         public double getValue(){
    return this.value;}

    public int compareTo(Object o){
               if(!(o instance of Double)) return -1;

        anotherDouble = (Double)o;
        setValue(anotherDouble .getValue());
                 return 0;
    }  
    }