-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClassStart5.java
More file actions
33 lines (25 loc) · 991 Bytes
/
Copy pathClassStart5.java
File metadata and controls
33 lines (25 loc) · 991 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 class1;
public class ClassStart5 {
public static void main(String[] args) {
Student student1;
student1 = new Student();
student1.name = "학생1";
student1.age = 15;
student1.grade = 90;
Student student2;
student2 = new Student();
student2.name = "학생2";
student2.age = 16;
student2.grade = 80;
Student[] students = {student1, student2};
for (int i = 0 ; i < students.length; i++) {
System.out.println("이름 : " + students[i].name + " 나이 : " + students[i].age + " 성적 : " + students[i].grade);
}
for (int i = 0 ; i < students.length; i++) {
Student s = students[i];
System.out.println("이름 : " + s.name + " 나이 : " + s.age + " 성적 : " + s.grade);
}
for (Student s : students)
System.out.println("이름 : " + s.name + " 나이 : " + s.age + " 성적 : " + s.grade);
}
}