my dog learned polymorphism
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 Java SE 8 Programmer I Study Guide this week in the OCAJP 8 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="" target="_blank" rel="nofollow"></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.
I agree. Here's the link:
subject: Method Invocation Problem
It's not a secret anymore!