There are 4 ways of creating objects in java.
1.Using new operator :
Employee obj=new Employee();
Here we are creating Employee class object ‘obj’ using new operator.
2.Using factory methods :
Here, we are creating NumberFormat class object using factory method getNumberInstance().
3. Using newInstance() method. Here, we should follow two steps, as:
a.First, store the class name ‘Employee’ as a String into a object. For this purpose, factory method forName() of the class ‘Class’ will be useful.
b.Next, create another object to the class whose name is in the object c. For this purpose, we need newInstance() method of the class ‘Class’, as:
4.By cloning a already available object, we can create another object. Creating exact copy of a existing object is called ‘cloning’.
Employee obj1=new Employee();