Hello all,
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
| char id = '2'; String name = "Tile"+id; Tile t = new name(); |
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?