The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
August 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

reply

Posted by aasc50 on August 28, 2001 at 9:05 PM

> does anyone know how i can call a method whose name
> is determined dynamically? for instance, if i have two
> methods:

> public void method0(){
> }

> public void method1(){
> }

> and i want to call the method based on the value
> of x (without using an if statement), can i do
> so? in other words, instead of calling method0()
> or method1(), can i call, so to speak, methodx(),
> which, if x is 0, will call method0() and, if x
> is 1, will call method1()?






Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us