Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Java, is this possible?

Name: Anonymous 2009-01-26 19:43

Can I take a string that has a class name and create a new class from it? I can do this in C# but I have no idea how to do so with Java.

Name: Anonymous 2009-01-26 20:55

Okay I'm doing this:
Class.forName(somename).getConstructor().newInstance(x, y, somecustomclass);

but I'm getting back this:

java.lang.NoSuchMethodException: ((somename's contents, it's a valid class)).<init>()
    at java.lang.Class.getConstructor0(Unknown Source)
    at java.lang.Class.getConstructor(Unknown Source)

There is a public constructor and it does accept those parameters, so I'm still lost(but hopefully really close).

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List