Hi. I am having this problem. I know the solution but i want to know why the problem happened?

i have this:
if (obj.getClass() == Student.getClass())
Student temp = (Student)obj;

I get a compilation error, non-static methode getClass() cannot be referenced from a static context.

i am using this code instead of: if (obj instenceof Student)
When i use: if (obj.getClass() == getClass()) i don't have a problem.
So can anyone please explain what the error means? Why is it saying i am calling from a static context. the method this code is in is not static. i am calling it from the equals method in the Student class.

thanks.