From ec23dabc4e64e4f93d7b812332e301f78ae37fbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 16 Feb 2017 12:16:09 +0100 Subject: java : add CallbacksTest --- java/CallbacksTest.java | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 java/CallbacksTest.java diff --git a/java/CallbacksTest.java b/java/CallbacksTest.java new file mode 100644 index 0000000..8a4d73f --- /dev/null +++ b/java/CallbacksTest.java @@ -0,0 +1,29 @@ + +abstract class Callback +{ + public abstract TRet call(TParam p); +} + +class Caller +{ + private Integer doCall(String s, Callback cb) + { + return cb.call(s); + } + + public Integer convert(final String s) + { + return doCall(s, new Callback() { + public Integer call(String s) { return Integer.parseInt(s); } + }); + } +} + +public class CallbacksTest +{ + public static void main(String [] args ) + { + Caller c = new Caller(); + System.out.println(c.getClass().getName() + " " + c.convert("666")); + } +} -- cgit v1.1-2-g2b99