this

https://qiita.com/hp_kj/items/9ffe03bf2919c99b964a https://qiita.com/hp_kj/items/789a7fb7e922745f8bd9 At the beginning, if I had a solid understanding of formal and actual arguments, I feel that my understanding would have progressed faster.


public class Monster {
	int hp = 100;
	int mp = 20;
	Monster(int hp ,int mp){
		this.hp = hp;//1
		this.mp = mp;
	}

// 1 this.hp = hp this.hp is the hp of the instance created from this class. It is the part of int hp = 100 ;.

= hp is the formal argument hp. Because hp of this class = hp of the formal argument Reads the value that was in the actual argument when calling Monster (int hp, int mp).

So, to summarize The formal argument hp is included in the hp of the instance created from this class.

Recommended Posts

this
About this ()
I checked this