getClass() returning java.lang.Class [Reflection] -


Then after obtaining the parameter for a method via reflection:

  class & Lt; ? & Gt; [] Parameters = m.getParameterTypes ();   

And suppose I'm piping through the methods and I'm searching for a method with only one parameter:

  Params.length & gt; 1) {continue; }   

Parameter Length Length 1:

  Class   

When I try to print the parameter class with the getClass () method, it returns the java.lang.Class.

However, when I get the Superclass GetSuperclass () method, it gives superclass.

For example:

  System.out.println (par.getClass ()); Println (par.getSuperclass ());   

Let us assume the parameters of the method "Player Death Avent" is a class, which extends the "Event" category.

It is being said, the output may be:

  java.lang.Class org.mypackage.Event   

Is there any reason to do this? I have found a way along with GetCanonicalName, but I am very curious why this happens.

Returns the class object for that example class is the object, so returns class for getClass () class class - a different class Is an example of par value .

However, class to getClass () by for the super class of the object. Call instead for

not to get player document .

  System.out.println (par.getName ());    

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -