Bear with me on this one... I'm having a little trouble finding the words to explain what I want to do.
I have 26 classes. Each of which have methods with the same name, return type and parameters. The class names are aWord(), bWord(), cWord etc.
The methods accept a single char as a parameter and return a String[].
The following code works, but is super lengthy, and I would have to do it every time I want a different method:
if (firstChar == 'a'){aWord word = new aWord(); wordArray = word.returnWordArray();}
else if (firstChar == 'b'){bWord word = new bWord(); wordArray = word.returnWordArray();}
else if (firstChar == 'c'){cWord word = new cWord(); wordArray = word.returnWordArray();}
else if (firstChar == 'd'){dWord word = new dWord(); wordArray = word.returnWordArray();}
Ideally, I'd be able to have something like:
String className = char + "Word";
className thisClass = new className();
String[] stringy = className.returnWordArray();
Any idea what a) I'm talking about and b) how I would go about doing it?