# Replacing constructor calls with factory method invocations

To replace calls to a constructor with calls to an equivalent factory method:

- In a Java editor or Java view, select the constructor declaration
- Do one of the following:
  - From the menu bar, select Refactor > Introduce Factory or
  - From the pop-up menu, select Refactor > Introduce Factory

You will be asked what to name the new factory method, on what class it should be placed, and whether to make the constructor private when the refactoring is complete. When the refactoring executes, it will create the new factory method, which will call the selected constructor and return the created object. All references to the constructor will be replaced by calls to the new factory method.

Refactoring actions
Refactoring dialogs
Java preferences