Re: Calling a method
- From: kaeli <tiny_one@xxxxxxxxxxxxxxxxxx>
- Date: Thu, 21 Apr 2005 12:41:21 -0500
In article <Q8adnTn68-5TSPrfRVn-oQ@xxxxxxxxxxx>, jm1@xxxxxxxxxxxx enlightened
us with...
> Here's another thing I'm trying to do that I hope someone can help with.
> I'd like to call a method on an instance of a class using a string as
> the method name. Something like anInstance.perform("getName"), which
> would call the method getName() on the instance and return the value
> from that.
>
> Any ideas on that?
You have to use reflection to do that sort of thing. There's nothing as
simple as just one line of code for it (like javascript and asp have), no.
Here are a couple options.
http://mindprod.com/jgloss/eval.html
--
--
~kaeli~
If a book about failures doesn't sell, is it a success?
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
.
- References:
- Calling a method
- From: cdx
- Calling a method
- Prev by Date: Is There a Java Process ID For Each Process?
- Next by Date: Re: Calling a method
- Previous by thread: Calling a method
- Next by thread: Re: Calling a method
- Index(es):
Relevant Pages
|