Is there any way that I can take a String and somehow use it as if its the name of one of my declared Objects? For example, if I have an Animal named germanShephard, is there some way I could say String gerSh = "germanShephard"; and then treat gerSh as if it was the equivalent of saying germanShephard in my program?
BestJewSinceJC 700 Posting Maven
Recommended Answers
Jump to PostIf you make your object Serializable then you can store information about the object in String form. It won't be as readable as "germanShepard" but you could store objects serials somewhere to enter. Doesn't sound too practical.
Another thing you can do is make a factory class. The class would …
Jump to PostBestJew: Yeah, I meant an if statement. Reflection is probably overkill for your stated requirements.
Jump to Post> Can anyone provide a reasonable example of a situation that needs reflection and a short explanation of why?
We use it on our current project for dynamic configuration of our UI. All panel components share an interface and with a simple XML file we can reconfigure the frames and …
Jump to PostCan you elaborate somewhat on the first example? The second example seems to make sense - you have a table and its layout set ahead of time, and based on what Strings are input, that table looks up the classnames (presumably each String represents a classname?) then fills the table …
Jump to PostDo you mean that depending on what the contents are of the XML file, different panels would appear which are created from classes that have their own content... but that the type and size of the panel are always the same? Because I don't see how you could use different …
All 28 Replies
Antenka 274 Posting Whiz
destin 6 Junior Poster in Training
Alex Edwards 321 Posting Shark
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
BestJewSinceJC 700 Posting Maven
destin 6 Junior Poster in Training
BestJewSinceJC 700 Posting Maven
destin 6 Junior Poster in Training
BestJewSinceJC 700 Posting Maven
destin 6 Junior Poster in Training
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
BestJewSinceJC 700 Posting Maven
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
bionicseraph 0 Newbie Poster
BestJewSinceJC 700 Posting Maven
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
Alex Edwards 321 Posting Shark
bionicseraph 0 Newbie Poster
bionicseraph 0 Newbie Poster
BestJewSinceJC 700 Posting Maven
bionicseraph 0 Newbie Poster
BestJewSinceJC 700 Posting Maven
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
BestJewSinceJC 700 Posting Maven
Alex Edwards 321 Posting Shark
BestJewSinceJC 700 Posting Maven
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
Ezzaral commented: Good reference. +15
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.