๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Java

[Java] ์ƒ์„ฑ์ž ์˜ค๋ฒ„๋กœ๋“œ

by ์ฝ”๋”ฉํ•˜๋Š” ๋ถ•์–ด 2021. 2. 18.
๋ฐ˜์‘ํ˜•
package constructor;

public class Person {
	String name;
	float height;
	float weight;

	public Person() {  // ๋””ํดํŠธ ์ƒ์„ฑ์ž
	}

	public Person(String name) {  // ์ด๋ฆ„์„ ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์ž…๋ ฅ๋ฐ›๋Š” ์ƒ์„ฑ์ž
		name = name;
	}

	public Person(String name, float pheight, float weight) {  // ์ด๋ฆ„, ํ‚ค, ๋ชธ๋ฌด๊ฒŒ๋ฅผ ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์ž…๋ ฅ๋ฐ›๋Š” ์ƒ์„ฑ์ž
		name = name;
		height = height;
		weight = weight;
	}
}

-ํด๋ž˜์Šค์— ์ƒ์„ฑ์ž๊ฐ€ ๋‘ ๊ฐœ ์ด์ƒ ์ œ๊ณต๋˜๋Š” ๊ฒฝ์šฐ๋ฅผ ์ƒ์„ฑ์ž ์˜ค๋ฒ„๋กœ๋“œ๋ผ๊ณ  ํ•œ๋‹ค.

๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€