Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Joshua Cranmer Newsgroups: comp.lang.java.programmer Subject: Re: Passing a Method Name to a Method Date: Wed, 22 Jun 2011 22:30:42 -0400 Organization: A noiseless patient Spider Lines: 23 Message-ID: References: <81h4075t4gfjglji1n033rb20025ebho68@4ax.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 23 Jun 2011 02:30:44 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="bAymlyY9SkaJNa8Tz2rerw"; logging-data="12755"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Psm656/EAaKJH9C8ek+xZ6+npVJ5YVGM=" User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.16pre) Gecko/20110305 Lightning/1.0b3pre Thunderbird/3.1.10pre In-Reply-To: <81h4075t4gfjglji1n033rb20025ebho68@4ax.com> Cancel-Lock: sha1:5p3LBXwvABK8csvPl7uCB3JNm8s= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:5565 On 06/22/2011 03:46 PM, Gene Wirchenko wrote: > I want to pass a parameter of a method name to another method. No you don't. You essentially want to go with the interface approach, as the prior responders to myself have said. Java does not have a concept of a function pointer or method handle. It is possible to emulate this to some degree with reflection, but if you are contemplating calling Method.invoke, you are almost always doing something wrong. > static returntype ThisWay(formal parms) > {...} > > static returntype ThatWay(formal parms) > {...} Why are you having static methods (on the same class, I presume) for two different ways of parsing instead of using separate parser classes? -- Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald E. Knuth