๋ฐ์ํ
โถ ์ธ์คํด์ค ์ฌ๋ฌ ๊ฐ ์์ฑํ๊ธฐ
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)๋ผ๊ณ ํ๋ค.
๋ฐ์ํ
'Java' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Java] ํด๋์ค+์ธ์คํด์ค ๋ง๋ค๊ธฐ ์ค์ต (0) | 2021.02.18 |
---|---|
[Java] ์ฐธ์กฐ ๋ณ์์ ์ฐธ์กฐ ๊ฐ (0) | 2021.02.18 |
[Java] main( ) ํจ์๋ฅผ ํฌํจํ ์คํ ํด๋์ค ๋ฐ๋ก ๋ง๋ค๊ธฐ (0) | 2021.02.18 |
[Java] ํด๋์ค์ main( ) ํจ์ ํฌํจํ๊ธฐ (0) | 2021.02.18 |
[Java] ํด๋์ค ๊ธฐ๋ฅ์ ๊ตฌํํ๋ ๋ฉ์๋ (0) | 2021.02.17 |
๋๊ธ