Ricosta Collins
asked on
dynamic naming in java - using a variable name to create an instance
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.getSelectedValu e();
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 ?
//An item from a list is selected and stored in the variable departure as a string.
String departure = (String) listOrigin.getSelectedValu
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+(
Any ideas ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Asked and answered.