This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan 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 Android Security Essentials Live Lessons this week in the Android 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: 430
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.

It is sorta covered in the JavaRanch Style Guide.
subject: Using Method Invocations
Similar Threads
Change the color of a JTable cell on mouse click
Calling methods using dynamic binding
component layout not wrapping inside Panel
String split function and "||" String
detect textfield