一个例子:
-
在Boy.java类中
-
在Girl.java类中
![](https://images2018.cnblogs.com/blog/1190900/201807/1190900-20180720134429379-2128797266.png)
在marry方法中的this指的是这个方法所属的对象的引用,在这里指的是girl这个对象
-
在BoyGirlTest.java测试类中
-
更具体更深的内容可参考https://www.cnblogs.com/lixiaolun/p/4311863.html
更具体更深的内容可参考https://www.cnblogs.com/lixiaolun/p/4311863.html