The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
October 2000

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:

dynamic method name

Posted by PJS on October 12, 2000 at 11:41 AM

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()?

thanks,
pjs




Replies:
  • yes, you can Kishori Sharan October 12, 2000 at 10:55 PM (0)

Sponsored Links



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