Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!nx01.iad01.newshosting.com!newshosting.com!69.16.185.11.MISMATCH!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!postnews.google.com!s2g2000vby.googlegroups.com!not-for-mail From: Lino Ferrentino Newsgroups: comp.lang.java.programmer Subject: simple method to simulate function pointers in java Date: Fri, 2 Sep 2011 01:54:45 -0700 (PDT) Organization: http://groups.google.com Lines: 41 Message-ID: <94e54cff-4dab-4c82-ade8-736174705e51@s2g2000vby.googlegroups.com> NNTP-Posting-Host: 93.150.101.7 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1314953809 29428 127.0.0.1 (2 Sep 2011 08:56:49 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 2 Sep 2011 08:56:49 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: s2g2000vby.googlegroups.com; posting-host=93.150.101.7; posting-account=V_6pHwoAAAC-vL5nnbGnzmqvI6WyFnAa User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: HUALESNKRC X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.19) Gecko/2011081514 Iceweasel/3.0.6 (Debian-3.0.6-3),gzip(gfe) Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:7527 Maybe there are other methods... I use this: public final class b_callbacks { private b_callbacks(){ } public static interface void_f_void{ public void f(); } public static interface void_f_int{ public void f(int i); } } ---- when I want to use a function pointer import b_callbacks.void_f_int; private void_f_int my_callback; my_callback = new void_f_int(){ public void f(int i){ //code } }; to call the callback my_callback.f(42); ==== For each function pointer type we create an interface.