I am working on some code which takes a string input dynamically , so i chose reflection as i didnt find any other better approach for it ,
My current code:
Class xyzClass = Class.forName("com.example.Xyz");
Object abcObj = abcService.generateAbcObj("some string input");
Method method = xyzClass.getDeclaredMethod("add", abcObj); // i want to pass this abcObj to this declared method add but getDeclaredMethod takes class as a parameter
Can anybody suggest way to do in reflection as i want it in a dynamic way or any other way to achieve it in a better sense ?
Aucun commentaire:
Enregistrer un commentaire