- #1
lypaza
- 18
- 0
I have only 1 day to work on my lab. Hope someone could help me as soon as possible.
My problem is I don't know how to count how many objects are created in a class.
The first assignment is write a Java class, Student, that has the following instance variables: name (String), age (int), gpa (double), courseGrades (array of char: A, B, C, D, F)
The class also has methods that would calculate the GPA of the student.
Then test the program by creating some objects: Student s1 = new Student(); ... blah...blah
And the second assignment, today my instructor just added it, is count how many objects are created in the class.I just do a little like this :uhh:
I don't know I could count it due to what things
My problem is I don't know how to count how many objects are created in a class.
The first assignment is write a Java class, Student, that has the following instance variables: name (String), age (int), gpa (double), courseGrades (array of char: A, B, C, D, F)
The class also has methods that would calculate the GPA of the student.
Then test the program by creating some objects: Student s1 = new Student(); ... blah...blah
And the second assignment, today my instructor just added it, is count how many objects are created in the class.I just do a little like this :uhh:
Code:
public int getCount(){
int count = 0;
...
return count;
}
I don't know I could count it due to what things