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

[Java] ์ธ์Šคํ„ด์Šค ์—ฌ๋Ÿฌ ๊ฐœ ์ƒ์„ฑํ•˜๊ธฐ

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

โ–ถ ์ธ์Šคํ„ด์Šค ์—ฌ๋Ÿฌ ๊ฐœ ์ƒ์„ฑํ•˜๊ธฐ

package classpart;

public class StudentTest1 {
	public static void main(String[] args) {

		Student student1 = new Student();  // ์ฒซ ๋ฒˆ์งธ ํ•™์ƒ ์ƒ์„ฑ
		student1.studentName = "์•ˆ์—ฐ์ˆ˜";
		System.out.println(student1.getStudentName());

		Student student2 = new Student();  // ๋‘ ๋ฒˆ์งธ ํ•™์ƒ ์ƒ์„ฑ
		student2.studentName = "์•ˆ์Šน์—ฐ";
		System.out.println(student2.getStudentName());
	}
}

-new Student( )๋ฅผ ์„ ์–ธํ•˜๋ฉด Student ํ•˜๋‚˜๊ฐ€ ์ƒ์„ฑ๋˜๋Š”๋ฐ ๊ฐ Student๋Š” studentID, studentName ๋“ฑ์˜ ๋ฉค๋ฒ„ ๋ณ€์ˆ˜๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ๋‹ค. ๊ทธ ๋•Œ ์ด๋“ค ๋ณ€์ˆ˜๋ฅผ ์ €์žฅํ• ๋•Œ ์‚ฌ์šฉํ•˜๋Š” ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ํž™ ๋ฉ”๋ชจ๋ฆฌ(heap memory)๋ผ๊ณ  ํ•œ๋‹ค.

๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€