Saturday, January 23, 2010

Various ways in creating the object

1.Using new operator:
      A a=new A();
2.Using Reflections:
       A a=Class.forName("A").newInstance();
3.Using clone method:
      A a=new A();
      A b=a.clone();
Class A should implements cloneable interface
4.Using ClassLoader:
      A a =cL.loadClass("A").newInstance();
   cL is instance of ClassLoader.

No comments:

Post a Comment