Difference between Python self and Java this

后端 未结 4 984
暗喜
暗喜 2020-12-23 16:04

I had done a bit of Python long back. I am however moving over to Java now. I wanted to know if there were any differences between the Python \"self\" method and Java \"this

4条回答
  •  旧时难觅i
    2020-12-23 16:28

    From my perspective, the most obvious difference is that in java class, in the constructor, you need to specify the field

    this.radius = radius
    

    While in the python code, you don't have to do so, it's implicit.

提交回复
热议问题