Java system set up in the airship speed production methods to create objects

1. Use the new keyword
speed airship system set up to make q <277.03.4.83.6>
This is to create an object of the most common, conventional methods, but also the most simple way. By using this method, we can call any constructor to call (using the no-argument constructor default).
   
. 1
    the Employee
. 1 0 2. 3: // new new class. 19 # ORG / Programming / Mitra / exercises / Employe. 3: DUP. 4: // Method, 21 is the invokespecial # ORG / Programming / Mitra / exercises / the Employee "":. () V

2 using the newInstance class class ()

we can use newInstance class class () method to create the object. The newInstance () method calls the no-argument constructor to create an object.

In the following code, we have to create by calling newInstance () of an object:

the Employee EMP2 = (the Employee) the Class.forName ( "org.programming.mitra.exercises.Employee") newInstance ();.

, Or:
    
. 1
    the Employee EMP2 = the Employee .class.newInstance ();
. 1
    51 is: invokevirtual # 70 // Method, Java / lang / :( the Class.newInstance) Ljava / lang / Object;

Guess you like

Origin www.cnblogs.com/xinlidehua/p/11593157.html