Ask your own question, for FREE!
Computer Science 18 Online
OpenStudy (anonymous):

Hi friends , Is it possible to make a newInstance() of a class which doesn't have a default constructor?(java + reflection)

OpenStudy (anonymous):

I want to invoke the methods of Math class but it is not possible because the constructor of this class is private!and I cannot make a newInstance even when I use getDeclaredConstructors my code throw this exception :" can not access a member of class java.lang.Math with modifiers "private" ".what can I do to solve this problem?

OpenStudy (espex):

You cannot create an instance of Math because it has no constructors, default or otherwise, it consists of only methods. Basically it is a collection of function calls and not a collection of "types" that define a larger object. http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Math.html

OpenStudy (anonymous):

thanks!

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!