SE450: Java classes: 0-arg constructor [15/22] ![]() ![]() ![]() |
A zero arg constructor is needed by any code that calls the
new
operator on your class.
It is also needed by code that dynamically instantiates your class. This can be done as follows:
Class yourClass = Class.forName("se450.mwright1.hw4.Student"); Student student = (Student)yourClass.newInstance();
This kind of code is used in various application servers as well
JavaBeans are classes that need a 0-arg constructor to work properly by other Java classes as well