Monday, May 23, 2016


Ways to create object in java


there are six different ways to create object in java
  1. new keyword
  2. class.forName()=====CrunchifyObj object2 = (CrunchifyObj) Class.forName("crunchify.com.tutorial.CrunchifyObj").newInstance();
  3. clone()
  4. newInstance() ====CrunchifyObj.class.getClassLoader().loadClass("crunchify.com.tutorial.CrunchifyObj").newInstance();
  5. Deserialization
  6. use the Constructor class from the java.lang.reflect

for more details

No comments:

Post a Comment