Re: instruction java
On Tue, 13 May 2008 13:58:37 -0700 (PDT), atef <atefbeya@gmail.com>
wrote, quoted or indirectly quoted someone who said :
bon je veus comprendre les lignes marqu9s et surtout ces 3 l0:
constructor = learnerClass.getConstructor(new Class[]
{NumericEntries.class, boolean.class});
parameters = new Object[] {new SubEntries(entries), new
Boolean(regression)};
return (SingleSupervisedLearner)constructor.newInstance(parameters);
Merci
Here is my shot at a translation:
I wish to understand the marked lines especially these 3:
constructor = learnerClass.getConstructor (new Class []
{NumericEntries.class, boolean.class});
parameters = new Object [] {new SubEntries (entries), new Boolean
(regression)};
return (SingleSupervisedLearner) constructor.newInstance (parameters);
Thank you
see http://mindprod.com/jgloss/reflection.html
You are creating parameters that are arrays of values.
You get a handle to the desired constructor.
You create an object to held the parameter values to the constructor.
You call the constructor, passing it the list of parameters.
All that song and dance does is something like:
return new XXX ( aaa, bbb );
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com