The array initializer of the following form does not use explicitly new .
int ia[][] = { {1, 2}, null };
This creates an object ... by autoboxing:
Integer big = 9999;
Finally, the following result in creating objects somewhere in the programβs life cycle :-)
Class c = ThisClass.class; String s = "a literal"; enum SomeEnum { WON, CHEW, TREE }
(And there are many, many ways to do this using library methods ... or native code)
Under covers, any creation of a new object in pure Java includes either the new bytecode, or one of the 3 bytes of t new array . This probably includes all my examples.
Interestingly, Object.clone() and ObjectInputStream.readObject() use "magic" mechanisms to create instances that are not related to the bytecodes mentioned above and do not call constructors in the usual way.
source share