jax
jax

Reputation: 38583

Loading a class by its name MyClass.class - is this possible?

It is possible to load a class given a String and its name? ie "MyClass.class"

Further, is it possible to pass parameters to the constructor using this method?

Upvotes: 0

Views: 124

Answers (2)

aioobe
aioobe

Reputation: 420951

Have a look at Construct Object using class name.

Key methods being forName() and newInstance().

Upvotes: 4

In silico
In silico

Reputation: 52149

Yes, look up the Reflection API.

Upvotes: 0

Related Questions