In this context, class not a keyword, it is a special attribute ("class literal") of the class, denoting its corresponding instance of the class . For example, to get the class object of a String object, we do the following: String.class . The return value is an instance of the class that represents the String class (note the use of upper and lower case).
Here .class used for the actual class, to get the same result using one of its instances, we use the getclass() method. Continuing our example, this fragment returns the same class instance that matches String : "".getClass() .
To get around the idea - this snippet will always return true for any class with the corresponding instance that you want to check:
"".getClass().equals(String.class)
source share