troubleshooting Question

dynamic naming in java - using a variable name to create an instance

Avatar of Ricosta Collins
Ricosta Collins asked on
Java* Object Oriented Programming
2 Comments1 Solution182 ViewsLast Modified:
Dynamically naming new java object.

//An item from a list is selected and stored in the variable departure as a string.

String departure = (String) listOrigin.getSelectedValue();

I want to then use this variable to create an instance in order to access object properties/data.

i.e.
departure accessData = new departure

Data is stored in a class with the same name as the departure if that makes sense, but in a different package, hence why i need to create an instance. I need to access the data in that departure class.

accessData.get+departure+() //method can then be called so data can be returned

Any ideas ?
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros