Michael,

I think what you need is some reflection to sort out your problem:

   String className = "red";
   Class c = Class.forName(className);
   Object o = c.newInstance();
   Red red = (Red)o;

Does this help?

Ramsay



Michael Ni wrote:

i will pay $2 usd if you can solve my problem. i'll send check by mail or paypal.

my problem is i have a String variable s which stores the name of the instance i want to create. how do i convert that variable to java code so that i can use it in my java code.

for instance

this is what i want to do

blue.use();
red.use();

but have somethign like
s = "blue";
something(s).use();
s = "red";
something(s).use();

which does the samething as above

mike


_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963



--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

============================================================================
A R K E M E D I A T E C H N O L O G I E S L T D VIEW POINT BASING VIEW BASINGSTOKE HAMPSHIRE RG21 4RG http://www.arkemedia.com mailto:[EMAIL PROTECTED] Tel : +44 1256 869 200 Fax : +44 1256 329 119 ============================================================================
The information in this e-mail and in any attachments is confidential and is intended solely for the attention and use of the named addressee(s). ============================================================================
If you are not the intended recipient, or a person responsible for passing it on to the intended recipient, you are not authorised to hold a copy of this information and you must therefore not disclose, copy, distribute, or retain this message or any part of it. MAILTO:[EMAIL PROTECTED] ============================================================================




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to