Hello friends.

Can anybody tell me how many ways exist to create the instance of class. i know only two ways to create the instance of class.
1. using new operator
2. using Class.forName()

can anybody tell me more method. someone told me that there is more than 5 method to create the instance of class.

thanks in advance

Recommended Answers

All 7 Replies

the defineClass method of class loader could instanciate a calss either.
hope it helps.

Before asking here you could have looked up "Creation of New Class Instances" in the Java Language Specification.

Yes you can found more information in the the java language specification 3.0
precisely the chapter 12
12-2 Loading of calsses and Interfaces.
hope it helps.

No help, i check the java language specification 3.0 and not able to find the satisfactory answer, i also check the point 12.5 Creation of New Class Instances but still not happy. could you please tell me.

sorry if i am asking wrong question or in wrong section.

So check the javaDoc of the classLoader; or just read the ClassLoader.java in the package java.lang.

hope it helps.

In fact I did not now in what context you'r working in; but the aproche I'm tolking about is when you'r writing a dynamique proxy class generator or aspect weaver.

OK, one of my friend told me four way to create the instance of class or you can say the way of creation of object.

1. new operator
2. Class.forName()
3. .clone() method
4. deserialzation

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.