Normally a constructor will execute when will we create a object for a class. but my question, is it possible to create a object with out executing a constructor?
Asked
Active
Viewed 69 times
-3
-
2http://stackoverflow.com/questions/3488097/is-it-possible-to-create-an-instance-of-an-object-in-java-without-calling-the-co – nano_nano Oct 28 '15 at 12:26
-
2There are loads of ways: http://stackoverflow.com/questions/16607261/instantiate-objects-without-using-new-operator – Paul Boddington Oct 28 '15 at 12:26
-
Maybe look here: http://stackoverflow.com/questions/3488097/is-it-possible-to-create-an-instance-of-an-object-in-java-without-calling-the-co – Oct 28 '15 at 12:27
-
Why would you want to? – duffymo Oct 28 '15 at 12:27
-
Please do a little search before asking such questions. – Shivam Oct 28 '15 at 12:27
-
If you want to construct you have to construct (i. e call constructor either *explictly* via `new` or implicitly via *reflection* etc.). – Dmitry Bychenko Oct 28 '15 at 12:29
1 Answers
0
Without any byte code manipulation and dirty hacks, no matter what, your constructor always executes on Object creation. If you do not pass any args, it will surely invoke your default constructor.
You are wanting to live in a home, without building it ;)

Avinash A
- 91
- 5
-
`clone` and `ObjectInputStream#readObject` are not really dirty. At most slightly shady... – Thilo Oct 28 '15 at 12:33