You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Donie Kelly <do...@tecnomen.ie> on 2003/04/02 12:21:34 UTC
RE: instance names problem will pay $2 for solution
This is a free service :) Don't think you can buy your answers here :)
Donie
-----Original Message-----
From: Michael Mattox [mailto:michael.mattox@verideon.com]
Sent: 02 April 2003 11:31
To: Tomcat Users List
Subject: RE: instance names problem will pay $2 for solution
When you create the instances (blue, red, etc.) store them in a hashtable.
SomeObject blue = new SomeObject();
ht.put("blue", blue);
then:
public void callUse(String color) {
SomeObject o = ht.get(color);
o.use();
}
If your instances aren't of the same type, then define an Interface (for
example they all have a method called "use") and use that instead of
SomeObject.
> -----Original Message-----
> From: Michael Ni [mailto:mikeni1225@hotmail.com]
> Sent: Wednesday, April 02, 2003 12:24 PM
> To: tomcat-user@jakarta.apache.org
> Subject: instance names problem will pay $2 for solution
>
>
> 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: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org