Accesing a function via string stored in Hashtable
问题 If I have function names stored as strings in a Hashtable. Is there a way to access the functions via the stored strings? EDIT I'm afraid the platform that i'm working on CLDC1.1/MIDP2.0 does not support Reflection. Any workaround possible? 回答1: Just use a big long list of else-ifs: [...] } else if ("foo".equals(function)) { target. foo(); } else if ("bar".equals(function)) { target. bar(); [...] (Although I generally don't like attempting vertical alignments in source, I think in cases like