I would like to be able to call a function based on its name provided by a string. Something like
public void callByName(String funcName){
this.(funcName)();
}
I have searched a bit into lambda funcions but they are not supported. I was thinking about going for Reflection, but I am a bit new to programming, so I am not so familiar with the subject.
This whole question was brought up on my java OOP class, when I started GUI (Swing, swt) programming, and events. I found that using object.addActionCommand()
is very ugly, because I would later need to make a Switch and catch the exact command I wanted.
I would rather do something like object.attachFunction(btn1_click)
, so that it would call the btn1_click
function when the event click was raised.