Java

[Java] ν΄λž˜μŠ€μ— main( ) ν•¨μˆ˜ ν¬ν•¨ν•˜κΈ°

μ½”λ”©ν•˜λŠ” λΆ•μ–΄ 2021. 2. 18. 03:39
λ°˜μ‘ν˜•

β–Ά ν΄λž˜μŠ€μ— 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을 μ°Έμ‘°λ³€μˆ˜λΌκ³  ν•˜κ³ , 이 λ³€μˆ˜κ°€ μƒμ„±λœ μΈμŠ€ν„΄μŠ€λ₯Ό 가리킨닀.

λ°˜μ‘ν˜•