Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail From: "Fuschia, President-Elect of the Bright Purplish-Green Council" Newsgroups: comp.lang.java.programmer Subject: Re: Passing a Method Name to a Method Date: Wed, 22 Jun 2011 16:00:46 -0400 Organization: IBM Lines: 19 Message-ID: References: <81h4075t4gfjglji1n033rb20025ebho68@4ax.com> NNTP-Posting-Host: GSStY+rpfPQ/lpqiHn8ioQ.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Xnews/2006.08.24 X-Notice: Filtered by postfilter v. 0.8.2 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:5543 On 22/06/2011 3:46 PM, Gene Wirchenko wrote: > Dear Jav'ers: > > Maybe I will find this after searching more, but so far, no good. > > I want to pass a parameter of a method name to another method. > > N.B.: I do not want to pass the method name as a string. I want > to pass it as a pointer / reference / whatever term is used for this > in Java. Unfortunately, you can't do this easily or efficiently (you'd need to use the Reflection API's Method objects) in Java; what you really want is a functional language like Clojure or Scala. If you really must use Java, define an interface that ThisWay and ThatWay can be instances of and which specify a parse method, and pass an instance to the parser class's method. (The so-called "strategy pattern".)