ALL IS WELL:
Kumar
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
luck, db
There are no new questions, but there may be new answers.
Darryl Burke wrote:It would help if you were to PostRealCode and UseCodeTags.
Check out the API for java.lang.reflect.Constructor<T>#newInstance(Object... initargs)
ALL IS WELL:
Kumar
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Wouter Oet wrote:Why do you want to do this? Reflection is a complex concept, performance is worse in comparison with using constructors the normal way, it's certainly not beginning Java and these kinds of problems can usually be solved with a good architecture.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Rob Prime wrote:Because the class depends on user input. If that's really necessary then reflection is the only way to go.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Rob Prime wrote:
Wouter Oet wrote:Why do you want to do this? Reflection is a complex concept, performance is worse in comparison with using constructors the normal way, it's certainly not beginning Java and these kinds of problems can usually be solved with a good architecture.
Because the class depends on user input. If that's really necessary then reflection is the only way to go.
Kumar,
first of all, please UseCodeTags, as Darryl already asked you to. You can edit your post to add them.
Secondly, you have already been given hints on how to do this. Darryl even mentioned the class and method to use. Combined with my advice to check out java.lang.Class you should be able to get an instance of Darryl's class.
ALL IS WELL:
Kumar
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Kumar Maddu wrote:
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
ALL IS WELL:
Kumar
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
ice is for people that are not already cool. Chill with this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|