๋ฐ์ํ
โถ ํด๋์ค์ main( ) ํจ์ ํฌํจํ๊ธฐ
package classpart;
public class Student {
int studentID;
String studentName;
int grade;
String address;
public String getStudentName() {
return studentName;
}
public static void main(String[] args) { // main() ํจ์
Student studentAhn = new Student();
studentAhn.studentName = "์์ฐ์";
System.out.println(studentAhn.studentName);
System.out.println(studentAhn.getStudentName());
}
}
Student studentAhn = new Student();
Student ํด๋์ค ์๋ฃํ์ผ๋ก studentAhn ๋ณ์๋ฅผ ์ ์ธํ๊ณ
new Student( );๋ก Student ํด๋์ค๋ฅผ ์์ฑํ์ฌ studentAhn์ ๋์ ํ๋ค๋ ๋ป.
์ด๋, studentAhn์ ์ฐธ์กฐ๋ณ์๋ผ๊ณ ํ๊ณ , ์ด ๋ณ์๊ฐ ์์ฑ๋ ์ธ์คํด์ค๋ฅผ ๊ฐ๋ฆฌํจ๋ค.
๋ฐ์ํ
'Java' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Java] ์ธ์คํด์ค ์ฌ๋ฌ ๊ฐ ์์ฑํ๊ธฐ (0) | 2021.02.18 |
---|---|
[Java] main( ) ํจ์๋ฅผ ํฌํจํ ์คํ ํด๋์ค ๋ฐ๋ก ๋ง๋ค๊ธฐ (0) | 2021.02.18 |
[Java] ํด๋์ค ๊ธฐ๋ฅ์ ๊ตฌํํ๋ ๋ฉ์๋ (0) | 2021.02.17 |
[Java-๊ธฐ์ด] ํด๋์ค ยท ๋ฉ์๋ ๊ธฐ์ด, ์ฌ์น์ฐ์ฐ (0) | 2021.02.16 |
[Java] ์ฌํ ๋ฌธ์ (0) | 2021.02.16 |
๋๊ธ