# フィールドの導入

> For the complete documentation index, see [llms.txt](https://www.jetbrains.com/ja-jp/help/idea/llms.txt).

> **TL;DR**
> `リファクタリング | 抽出 / 導入 | フィールド`
>
>
>
> `Ctrl+Alt+F` (Windows), `⌘ ⌥ F` (macOS), `⌘ ⌥ F` (IntelliJ IDEA Classic (macOS)), `⌘ ⌥ F` (macOS System Shortcuts), `Ctrl+Alt+F` (XWin), `Ctrl+Alt+F` (GNOME), `Ctrl+Alt+F` (KDE), `Ctrl+Alt+F` (Emacs), `Ctrl+Alt+F` (Sublime Text), `Ctrl+Alt+F` (Sublime Text (macOS)), `Ctrl+R, F` (Visual Studio), `⌘ R, F` (Visual Studio (macOS)), `Alt+Shift+E` (NetBeans), `Ctrl+Alt+F` (Eclipse), `⌘ ⌥ F` (Eclipse (macOS))

フィールドの導入 リファクタリングでは、新しいフィールドを宣言し、選択した式で初期化することができます。 元の式はフィールドの使用箇所に置き換えられます。

Procedure: その場でフィールドを抽出する

1. フィールドに抽出するコード部分内にキャレットを置きます。

2. `Ctrl+Alt+F` (Windows), `⌘ ⌥ F` (macOS), `⌘ ⌥ F` (IntelliJ IDEA Classic (macOS)), `⌘ ⌥ F` (macOS System Shortcuts), `Ctrl+Alt+F` (XWin), `Ctrl+Alt+F` (GNOME), `Ctrl+Alt+F` (KDE), `Ctrl+Alt+F` (Emacs), `Ctrl+Alt+F` (Sublime Text), `Ctrl+Alt+F` (Sublime Text (macOS)), `Ctrl+R, F` (Visual Studio), `⌘ R, F` (Visual Studio (macOS)), `Alt+Shift+E` (NetBeans), `Ctrl+Alt+F` (Eclipse), `⌘ ⌥ F` (Eclipse (macOS)) を押すか、メインメニューで  `リファクタリング | 抽出 / 導入 | フィールド`  に移動します。

3. フィールドとして導入する式を選択します。

![式を選択する](https://resources.jetbrains.com/help/img/idea/2026.3/extract_field.png)

IntelliJ IDEA がコード内で複数の出現箇所を検出した場合、置き換える出現箇所を指定できます。

![フィールドの複数の出現箇所を抽出する](https://resources.jetbrains.com/help/img/idea/2026.3/extract_field_occurrences.png)

`Ctrl+Alt+F` (Windows), `⌘ ⌥ F` (macOS), `⌘ ⌥ F` (IntelliJ IDEA Classic (macOS)), `⌘ ⌥ F` (macOS System Shortcuts), `Ctrl+Alt+F` (XWin), `Ctrl+Alt+F` (GNOME), `Ctrl+Alt+F` (KDE), `Ctrl+Alt+F` (Emacs), `Ctrl+Alt+F` (Sublime Text), `Ctrl+Alt+F` (Sublime Text (macOS)), `Ctrl+R, F` (Visual Studio), `⌘ R, F` (Visual Studio (macOS)), `Alt+Shift+E` (NetBeans), `Ctrl+Alt+F` (Eclipse), `⌘ ⌥ F` (Eclipse (macOS)) を 2 回押して   フィールドの導入   ダイアログを開くと、可視性オプションや変数を初期化するためのオプションなどの詳細を指定できます。

![フィールドの導入ダイアログ](https://resources.jetbrains.com/help/img/idea/2026.3/extract_field_dialog.png)

## サンプル

`anotherClass.intValue();`  変数をフィールドに抽出してみましょう。 その結果、IntelliJ IDEA は選択された変数名を  `number`  に変更し、それを  `private int number`  フィールドとして宣言します。

|  前  |  後  |
| --- | --- |
|     ```JAVA public class Class {     AnotherClass anotherClass;     public void method() {         int a = 1;          int b = a + anotherClass.intValue();         int c = b + anotherClass.intValue();     } }  ```    |     ```JAVA public class Class {     public AnotherClass anotherClass;     private int number;      public void method() {         int a = 1;         number = anotherClass.intValue();         int b = a + number;         int c = b + number;     } }      ```    |

## See also

### リファレンス

[フィールドの導入ダイアログ](extract-field-dialog.html)

