summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2017-02-16 12:16:09 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2017-02-16 12:16:09 +0100
commitec23dabc4e64e4f93d7b812332e301f78ae37fbf (patch)
treea09a419c15608e96e1a396e57b81d61ee8d5d252
parent7cd57266593fe7cb9e08140f4405a93dd5c58303 (diff)
downloadshare-ec23dabc4e64e4f93d7b812332e301f78ae37fbf.zip
share-ec23dabc4e64e4f93d7b812332e301f78ae37fbf.tar.gz
java : add CallbacksTest
-rw-r--r--java/CallbacksTest.java29
1 files changed, 29 insertions, 0 deletions
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<TRet, TParam>
+{
+ public abstract TRet call(TParam p);
+}
+
+class Caller
+{
+ private Integer doCall(String s, Callback<Integer, String> cb)
+ {
+ return cb.call(s);
+ }
+
+ public Integer convert(final String s)
+ {
+ return doCall(s, new Callback<Integer, String>() {
+ 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"));
+ }
+}