> From: "Wim Ceulemans" <[EMAIL PROTECTED]>
> Date: Tue, 26 May 1998 08:45:30 +0200
> Does anyone has experience in passing a class as a parameter in java?
> I want to do something like call a method with as parameter a class
> name and then create instances of that class in that method. Is this
> Does anyone has experience in passing a class as a parameter in java?
You can pass the name of a class ("com.foo.package.Name") as a
parameter, and then so long as the class can be found either locally
on the client, or via the ARCHIVE=___.jar tag, you can create an
instance via something like:
> Does anyone has experience in passing a class as a parameter in java?
> I want to do something like call a method with as parameter a class name and
> then create instances of that class in that method. Is this possible?
try this:
public Object makeInstance(String sClassName)
{
Class rC
Yes. If your class has a no-arg constructor, just do like this:
void method(Class c)
{
...
Object o = c.newInstance();
... // use 'o'
}
Otherwise, look for a Constructor class documenation from
java.lang.reflect package to create and initialize your object
Hi
Does anyone has experience in passing a class as a parameter in java?
I want to do something like call a method with as parameter a class name and
then create instances of that class in that method. Is this possible?
Regards
Wim Ceulemans
Nice Software Solutions
Eglegemweg 3, 2811 Hombeek
Te