Creating an instance for a class?

Look at the source code for the Integer class, just stumble on this line below

Class<Integer> TYPE = (Class<Integer>) Class.getPrimitiveClass("int"); 

And getPrimitiveClass is its own method.

  static native Class getPrimitiveClass(String name); 

Why did he become a native method? really want to know.

How to create an instance for Class ? Does this differ in the usual way to create an instance for ex: Ex e = new Ex() ?

+6
source share
1 answer

The comment above the method definition says:

 /* * Return the Virtual Machine Class object for the named * primitive type. */ static native Class getPrimitiveClass(String name); 

Since the virtual machine (at least Sun) is implemented in C, I would suggest that this is the reason the native method.

+2
source

All Articles