wood burning stoves 2.0*
The moose likes Java in General and the fly likes Method Invocation Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Method Invocation Problem" Watch "Method Invocation Problem" New topic

Method Invocation Problem

Serkan Demir
Ranch Hand

Joined: Feb 03, 2005
Posts: 61
I have a question on method invocation. Assume that i have a method, named "Factory(int code)".And it executes a pre-defined method according to its parameter. Do you know there is a way for such a method invocation,or in other words,transition from String to method invocation?

public void Factory(int code){
String methodName="getDescription_"+code+"()";
/* How can i invoke "methodName" method at this line?? */


A guy from Turkey<br /><a href="http://blogspot.serkandemir.com" target="_blank" rel="nofollow">http://blogspot.serkandemir.com</a>
D Rog
Ranch Hand

Joined: Feb 07, 2004
Posts: 472

Nothing simple:

Retire your iPod and start with HD Android music player Kamerton | Minimal J2EE container is here | Light weight full J2EE stack | and build tool | Co-author of "Windows programming in Turbo Pascal"
Serkan Demir
Ranch Hand

Joined: Feb 03, 2005
Posts: 61
thanks lot.
It is sorta covered in the JavaRanch Style Guide.
subject: Method Invocation Problem