Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using Method Invocations

 
Kenneth Kim
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's one way...
 
Qunfeng Wang
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Julien Grenier
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
if you are using java 5.0 you can do something like that.




Julien
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic