public class FunctionTest {
public static int addNum(int num1, int num2) {
int result = num1 + num2;
return result;
}
public static void sayHello(String greeting) {
System.out.println(greeting);
}
public static int calcSum() {
int sum = 0;
int i;
for (i = 0; i <= 100; i++) {
sum += i;
}
return sum;
}
public static void main(String[] args) {
int n1 = 10;
int n2 = 20;
int total = addNum(n1, n2);
System.out.println(total);
sayHello("안녕하세요");
total = calcSum();
System.out.println(total);
}
}
public class Student {
public int studentId;
public String studentName;
public String address;
public void showStudentInfo() {
System.out.println(studentId + "학번 학생의 이름은 " + studentName + "이고, 주소는 " + address);
}
public String getStudentName() {
return studentName;
}
public void setStudentName(String name) {
studentName = name;
}
}
----------------------------------------------------------------
public class StudentTest {
public static void main(String[] args) {
Student studentLee = new Student(); // 인스턴스
studentLee.studentId = 12345;
studentLee.setStudentName("lee");
studentLee.address = "서울 강남구";
studentLee.showStudentInfo();
Student studentKim = new Student();
studentKim.studentId = 54321;
studentKim.studentName = "Kim";
studentKim.address = "경기도 성남시";
studentKim.showStudentInfo();
}
}
https://zeddios.tistory.com/233
https://junghyun100.github.io/%ED%9E%99-%EC%8A%A4%ED%83%9D%EC%B0%A8%EC%9D%B4%EC%A0%90/
https://velog.io/@goyou123/%ED%95%A8%EC%88%98%EC%99%80-%EB%A9%94%EC%86%8C%EB%93%9C%EC%9D%98-%EC%B0%A8%EC%9D%B4%EC%A0%90