Link to home
Start Free TrialLog in
Avatar of dkim18
dkim18

asked on

Class.forName(visitNoteClass).newInstance();

hi!
I need to know what this line does in detail?
Class.forName(visitNoteClass).newInstance();

++++++++++++++++++++++      

      private String visitNoteClass = null;
      private HttpServletRequest request = null;
      private ActionMapping mapping = null;
...
...
            
      }
      public ActionForward execute() {
   
            VisitNoteType v = null;
            Connection conn = null;
            OraConnDispenser ocd = null;
            
            try {
                   v = (VisitNoteType) Class.forName(visitNoteClass).newInstance();            
                   v.init(request);
                   ocd = new OraConnDispenser(null);
                   conn = ocd.getConnection();
...
...
++++++++
thanks,
SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>>u wouldnt be able to differentiate if an exception happends in Class.forName or in the newInstance()..

Not strictly true, as different subclasses of Excepetion are thrown, although it does make the code more readable/maintainable
:-)