-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMethod2.java
More file actions
33 lines (24 loc) · 874 Bytes
/
Copy pathMethod2.java
File metadata and controls
33 lines (24 loc) · 874 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
package ref;
public class Method2 {
public static void main(String[] args) {
Student student1 = createStudent("학생1", 15, 90);
Student student2 = createStudent("학생2", 16, 80);
printStudent(student1);
printStudent(student2);
}
public static Student createStudent(String name, int age, int grade) {
Student student = new Student();
student.name = name;
student.age = age;
student.grade = grade;
return student;
}
public static void printStudent(Student student) {
System.out.println("이름 : " + student.name + ", 나이 : " + student.age + ", 성적 : " + student.grade);
}
private static void initStudent(Student student, String name, int age, int grade) {
student.name =name;
student.age =age;
student.grade =grade;
}
}