I found that .class could be applied to primitives and void. I completely don't understand what . means then. I always thought that . is like c++ ->, so it returning a reference to a field and then dereferecing it. But how this can be applied to the primitive types? Or does this mean that primitive types in java are also objects? Please, advise. Many thanks.
The C language has been called "high level assembler", because there's almost always a one-to-one correspondence between a language construct and specific assembly instructions. Since the first C++ compiler was a special preprocessor for a C compiler, C++ is pretty much the same way. The dot operator does indeed translate into a very specific kind of dereferencing.
But Java is different; it's a somewhat higher level language, and many language constructs don't map directly onto virtual machine instructions. Many operators give rise to different code depending on how they're used. The dot operator in Java is definitely one of those.
In Java, "dot class" construct is handled entirely by the compiler. Although it might look like it, no class actually has a member named "class", and could not, of course, since "class" is a reserved word in Java. Anyway, when the compiler sees ".class" attached to a type name, it know how to substitute the appropriate Class object. For primitives, there are Class objects available as constants named TYPE in the corresponding wrapper classes -- i.e. int.class is changed to java.lang.Integer.TYPE . For other types, the compiler creates a private member variable in the class being compiled to hold the Class object, and generates code to initialize that member using Class.forName() .