λ°μν
μ€λμ μ΄μ체μ , λ°μ΄ν°λ² μ΄μ€, λ€νΈμν¬, κ°λ°νκ²½μ λν κ°λ¨ν μ΄λ‘ μ λ°°μμ Java μμ μ 1μκ°λ°μ μνλ€.
β
β
β
*ν΄λμ€ κΈ°λ₯μ ꡬννλ λ©μλ
package classpart;
public class Student {
int studentID;
String studentName;
int grade;
String address;
public void showStudentInfo() {
System.out.println(studentName + "," + address); // μ΄λ¦, μ£Όμ
}
public String getStudentName() { // νμμ μ΄λ¦μ λ°ννλ getter λ©μλ
return studentName;
}
public void setStudentName(String studentName) { // νμ μ΄λ¦μ 맀κ°λ³μλ‘ μ λ¬
this.studentName = studentName;
}
public int getStudentID() {
return studentID;
}
public void setStudentID(int studentID) {
this.studentID = studentID;
}
public int getGrade() {
return grade;
}
public void setGrade(int grade) {
this.grade = grade;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
}
-get + μμλ©€λ²λ³μμ μ΄λ¦μ λΆμΌλ 첫 κΈμλ λλ¬Έμλ‘!
λ°μν
'Java' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
[Java] main( ) ν¨μλ₯Ό ν¬ν¨ν μ€ν ν΄λμ€ λ°λ‘ λ§λ€κΈ° (0) | 2021.02.18 |
---|---|
[Java] ν΄λμ€μ main( ) ν¨μ ν¬ν¨νκΈ° (0) | 2021.02.18 |
[Java-κΈ°μ΄] ν΄λμ€ Β· λ©μλ κΈ°μ΄, μ¬μΉμ°μ° (0) | 2021.02.16 |
[Java] μ¬ν λ¬Έμ (0) | 2021.02.16 |
[Java] μ€μ΅ (0) | 2021.02.16 |
λκΈ