Yes, We can create an object without using new operator. There are some other ways to create
objects other than using new operator. But, 95% of object creation in Java is done through new
operator only.
a) Using newInstance()
Method
1Class c = Class.forName("packageName.MyClass");
2
3 MyClass object = (MyClass) c.newInstance();
b) Using clone() method.
1 MyClass object1 = new MyClass();
2
3 MyClass object2 = object1.clone();
c) Using object deserialization
1 ObjectInputStream inStream = new ObjectInputStream(anInputStream );
2
3 MyClass object = (MyClass) inStream.readObject();
MyClass object = (MyClass) inStream.readObject();
d) Creating string and array objects
1 String s = "string object";
2
3 int[] a = {1, 2, 3, 4};