public class Student
{
 private String id;
 private String name;
 private double gpa;
 // เป็นการประกาศ กลุ่มของ Student
 public Student(String ID,String n, double GPA){
  id = ID;
  name = n;
  gpa = GPA;
 }
 public void getShow(){
  System.out.println("ID :  "+ id);
  System.out.println("Name : " + name);
  System.out.println("GPA  : " + gpa);
 }
}
 นี้เป็นตัวแรก พิมพ์ตามเค้า ไม่รู้ว่าเป็นอะไร ม้าง

 

public class Show_student
{
 public static void main(String[] args)
 {
  Student s[] = new Student[4];
  s[0] = new Student("1111","AAAAAAAAAAA",3.3);
  s[1] = new Student("2222","BBBBBBBBBBB",3.3);
  s[2] = new Student("3333","CCCCCCCCCCC",3.3);
  s[3] = new Student("4444","DDDDDDDDDDD",3.3);
   for(int i =0 ; i<4 ; i++){
    s[i] .getShow();
    System.out.println();
   }
 }
}

พอมาอีก อัน ก็พิมพตามเค้า ผล ออกมาเป็น