What's the difference between calling MyClass.class and MyClass.getClass()
First of all your question title is a bit misleading! .getClass() is a method defined in java.lang.Object
so any object in java can call it where as .class is called on the class itself(like public static variables). So the question should be (sticking to java naming conventions)
What's the difference between calling MyClass.class and myClassObject.getClass()
Now to actual differences
.getClass() is a native java method in java.lang.Object. This method will return java.lang.Class object corresponding to the runtime class
of the object on which it is invoked. So
Test t = new TestSubClass();
Class c2 = t.getClass();
System.out.println(c2);
will print class TestSubClass
where as .class will return the statically evaluated (known at compile time) class. It is actually Class object corresponding to the reference type pointing to the actual object.So
Test t = new TestSubClass();
Class c2 = Test.class;
System.out.println(c2);
will print class Test