Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>For such a thing you should in all cases try to have unified constructor parameters or a way to store the parameters per class.</p> <p>Now for your questions. <code>Class&lt;?&gt;</code> is a reference to a unknown class. Basically to any class. When using it its more or less equal to <code>Class&lt;Object&gt;</code> because all classes got <code>Object</code> as parent.</p> <p>For using constructors with multiple arguments you first need to fetch the fitting constructor. At this point its already possible to fetch errors that happen in case the class does not support instances with this configuration of arguments. Fetching the constructor works this way:</p> <pre><code>aClass.getConstructor(new Class[]{String.class, Object.class, ...});</code></pre> <p>This works with as many argument types as you like. Creating the new instance of the class then works this way:</p> <pre><code>constructor.newInstance(theString, theObject, ...);</code></pre> <p>The function <code>newInstanace</code> is implemented as many arguments as needed. So depending on how many arguments the constructor that was requested requires the <code>newInstance</code> function will be able to work with it.</p> <p>For all what you intend... maybe a proposal: Maybe its a option not to load the new objects using reflection but rather by storing instances of those objects and returning copies of the objects created using copy constructors or the <code>clone</code> method. In many cases this is less difficult to get running.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload