Example
| Before | After |
|---|---|
public void method() { List list = new LinkedList(); list.add("string"); } |
public void method() { List<String> list = new LinkedList<String>(); list.add("string"); } |
- Select the level of code transformation, which can be a method, a class, a package or directory, in the Project or Structure view, or place the cursor on the class or method name in the editor. If you want to apply generics to a single code fragment, just select it in the editor.
- On the main menu, or on the context menu of the selection, choose .
The Generify
dialog box appears.

- Define the refactoring options. Refer to the dialog description for details.
-
Preview and apply changes.


