This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Using Method Invocations Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Using Method Invocations" Watch "Using Method Invocations" New topic

Using Method Invocations

Kenneth Kim

Joined: Aug 11, 2005
Posts: 10
Hi I have the following code:

Do you see the part of my code with the XXXXX's? I have the user input the name of a color in the string earlier in the program. How do I use the string in place of the XXXX's? The name of the string is "color", quite appropriately.
marc weber

Joined: Aug 31, 2004
Posts: 11343

Here's one way...

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
Qunfeng Wang
Ranch Hand

Joined: Jan 28, 2005
Posts: 434
You can't pass [i]color[i/] as an arg to Color.Just use if-else to determine which Color to choose.

Anyone has better method?

To be or not to be. It's a question.
Julien Grenier
Ranch Hand

Joined: Sep 01, 2005
Posts: 41
if you are using java 5.0 you can do something like that.

I agree. Here's the link:
subject: Using Method Invocations
It's not a secret anymore!