|
@@ -0,0 +1,39 @@
|
|
|
+package com.sf.day06.ObjectArray;
|
|
|
+
|
|
|
+import com.sf.game.obj.ShellObj;
|
|
|
+import sun.text.UCompactIntArray;
|
|
|
+
|
|
|
+import java.util.Arrays;
|
|
|
+
|
|
|
+public class Student {
|
|
|
+ int number;
|
|
|
+ int state;
|
|
|
+ int score;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String toString() {
|
|
|
+ return "Student{" +
|
|
|
+ "number=" + number +
|
|
|
+ ", state=" + state +
|
|
|
+ ", score=" + score +
|
|
|
+ '}';
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ Student[] students = new Student[5];
|
|
|
+ for (int i= 0;i<students.length;i++){
|
|
|
+ Student student = new Student();
|
|
|
+ student.number = i+1;
|
|
|
+ student.state = (int)(Math.random()*5+1);
|
|
|
+ student.score = (int)(Math.random()*100+1);
|
|
|
+ students[i] = student;
|
|
|
+ }
|
|
|
+ System.out.println(Arrays.toString(students));
|
|
|
+ for (Student student : students) {
|
|
|
+ if(student.state == 3){
|
|
|
+ System.out.println(student);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|