解决方案 »

  1.   

    class Address
    {
    String detail ;
    public Address(String detail){
      this.detail = detail ;
    }
    }
    class User implements Cloneable
    {
    int age ;
    Address address ;
    public User(int age){
        this.age =age ;
    address = new Address("山东莱芜");
    }
    public User clone()
    throws CloneNotsupportedException   在eclipse中写代码时这行就提示错误,但不知如何修改?在定义这个类?还是引入?
    {
    return (User)super.clone() ;
    }
    }
    public class CloneTest
    {
    public static void main(String[] args)
    throws CloneNotSupportedException{
              User u1 = new User(23) ;
      User u2 = u1.clone();
      System.out.println(u1 == u2) ;
      System.out.println(u1.address == u2.address) ;  
    }
    }
      

  2.   

    throws CloneNotsupportedException修改为throws CloneNotSupportedException
    就是大写;
      

  3.   

    请使用IDE工具。MYECLIPSE,这些代码你肯定是手写一句句一的打上去的。IDE工具会自动检测这种小错误