-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMethod2.java
More file actions
35 lines (27 loc) · 942 Bytes
/
Method2.java
File metadata and controls
35 lines (27 loc) · 942 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package java02_basic.ref;
public class Method2 {
public static void main(String[] args) {
Student student1 = createStudent("학생1", 18, 49);
System.out.println("student1 = " + student1);
Student student2 = createStudent("학생2", 15, 83);
System.out.println("student2 = " + student2);
printStudent(student1);
printStudent(student2);
}
static Student createStudent(String name, int age, int grade) {
Student student = new Student();
System.out.println("student = " + student);
student.name = name;
student.age = age;
student.grade = grade;
return student;
}
static void initStudent(Student student, String name, int age, int grade) {
student.name = name;
student.age = age;
student.grade = grade;
}
static void printStudent(Student student) {
System.out.println("이름: " + student.name + " 나이: " + student.age + " 성적: " + student.grade);
}
}