I think the sunject's pretty self-explanatory. I use JDK 1.6.0 update 26, and created a new project with just one line to confirm this:
Boolean.class.newInstance();
and it throws the following:
Exception in thread "main" java.lang.InstantiationException: java.lang.Boolean
at java.lang.Class.newInstance0(Class.java:340)
at java.lang.Class.newInstance(Class.java:308)
Does it suppose to fail? If so, why?
The Boolean
class has two constructors, both take one argument. Calling Boolean.class.newInstance()
is trying to call a zero-arg constructor that doesn't exist.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With