ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
![](https://box.kancloud.cn/3bb50e4e61bc4c78f64cad57bed47712_710x416.png) ![](https://box.kancloud.cn/de8158c6f424cc1e74e9521cff000591_835x369.png) 下面就相当于把two对象赋值给three,two和three的信息就会一模一样 ~~~ package obj.a6; class Cat{ String name; int age; String color; public void set(String name,int age,String color){ this.name=name; this.age=age; this.color=color; } public String toString(){ return "姓名:"+name+"\t年龄:"+age+"\t颜色:"+color; } public Cat abc(){ return this; } } public class Test { public static void main(String[] args){ Cat one=new Cat(); Cat two=new Cat(); one.set("第一只猫", 5, "黑色"); two.set("第二只猫", 6, "白色"); Cat three=new Cat(); three=two.abc();//相当于three=two System.out.println(one); System.out.println(two); System.out.println(three); } } ~~~ ![](https://box.kancloud.cn/60893cab5930c4238fc6305980f2ffa3_411x132.png)