I'm just wondering if it's possible to create an object from a variable String. For example, I have four classes named Tile1, Tile2, ..., etc. Now say I have a String, from which an ID character (1 - 4) is incremented into the String, could I create a class-object from that String? Like so:

1 2 3

charid = '2'; // This character is arbitrary in my actual program, but just initiated as '2' for this example.Stringname = "Tile"+id;Tilet = newname(); // All Tile1...4 classes extend the main class, Tile.

Of course, the code above doesn't work because the compiler thinks I'm trying to create an object of class name, which doesn't exist. But is there any possible way to create an object of a class from a String, like above?

I'm assuming this happens since both my main Tile class and all of my Tile1...4 classes require parameters. Is there anyway to pass parameters to the newly created Object too?

EDIT: Yup, I get an error because my classes require parameters (I tested it by removing the parameter requirements of my classes). I guess I can just use a separate method, and after the Object is initiated, call that method.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org