Ways to create object in java
there are six different ways to create object in java
- new keyword
- class.forName()=====CrunchifyObj object2 = (CrunchifyObj) Class.forName("crunchify.com.tutorial.CrunchifyObj").newInstance();
- clone()
- newInstance() ====CrunchifyObj.class.getClassLoader().loadClass("crunchify.com.tutorial.CrunchifyObj").newInstance();
- Deserialization
- use the Constructor class from the java.lang.reflect
No comments:
Post a Comment