Skip to content

Instantly share code, notes, and snippets.

@mohnish
Created March 8, 2013 21:16
Show Gist options
  • Select an option

  • Save mohnish/5119939 to your computer and use it in GitHub Desktop.

Select an option

Save mohnish/5119939 to your computer and use it in GitHub Desktop.
class Management {
static listOfStudents = new ArrayList<Student>();
public static void main(String[] args) {
School wku = new School("Western Kentucky University");
Student macha = new Student("macha", 10, 8, wku);
Student mt = new Student("mt", 10, 8, wku);
addStudent(macha);
addStudent(mt);
System.out.println("Total number of students: " + listOfStudents.size());
}
static void addStudent(Student student) {
listOfStudents.add(student);
}
}
class School {
String name;
public School(String name) {
this.name = name;
}
}
class Student {
String name;
int rollNumber;
int standard;
School school;
public Student(String name, int rollNumber, int standard, School school) {
this.name = name;
this.rollNumber = rollNumber;
this.standard = standard;
this.school = school;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment