Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) {
- Object o = new Object() { public String s(String name) { return "Hello, " + name; } };
- try {
- System.out.println(((String) o.getClass().getDeclaredMethod("s", String.class).invoke(o, "Dennis")));
- } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
- | NoSuchMethodException | SecurityException e) {
- e.printStackTrace();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement