Re: reflection newInstance
- From: "Oliver Wong" <owong@xxxxxxxxxxxxxx>
- Date: Tue, 20 Sep 2005 22:20:43 GMT
"Mike Phelps" <mphelps@xxxxxxxxxxx> wrote in message
news:433088c6.172770550@xxxxxxxxxxxxxxxxx
> Object obj = Class.forName("java.lang.Integer").newInstance(); throws
> a java.lang.InstantiationException. why? what does it mean?
What does it say on
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/InstantiationException.html ?
> How can I
> build an Integer with a default value when all I have is a string:
> "java.lang.Integer".
You cannot. The Integer class
(http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Integer.html) doesn't
have a "default" value. You have to specify a value.
> It is from an xml file that contains type of an
> object, It could also be java.lang.Float or java.lang.Double.
See http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Float.html and
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Double.html
- Oliver
.
- References:
- reflection newInstance
- From: Mike Phelps
- reflection newInstance
- Prev by Date: reflection newInstance
- Next by Date: Re: reflection newInstance
- Previous by thread: reflection newInstance
- Next by thread: Re: reflection newInstance
- Index(es):
Relevant Pages
|
Loading