blob: 8a4d73f81f167bf0d12d9849101ba7da2e5af256 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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"));
}
}
|