0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

this

Last updated at Posted at 2018-09-02

https://qiita.com/hp_kj/items/9ffe03bf2919c99b964a
https://qiita.com/hp_kj/items/789a7fb7e922745f8bd9
自分が最初の頃、仮引数と実引数さえしっかり理解していたらもっと理解が早く進んだ気がする。


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はこのクラスから作られるインスタンスのhpです。int hp = 100;の部分のことです。

= hpは仮引数のhpです。
このクラスのhp = 仮引数のhpなので
Monster(int hp ,int mp)を呼んだときに実引数に入っていた値を読み出します。

なので、まとめると
このクラスから作られたインスタンスのhpに、仮引数のhpが入ります。

0
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?