Skip to main content

Split Initialization from Declaration


This Refactoring is used when the variable is declared and initialized in the same statement. It breaks this statement into two lines: separates the initialization from declaration. It is useful for conditional initialization, or when you need to widen the scope of the declaration.


Available when the caret is on a variable name in the statement where it is declared and initialized.


  1. Place the caret on a variable name in its initialized declaration.


    The blinking cursor shows the caret’s position at which the Refactoring is available.

    double a = 1.42;
  2. Press the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions menu.
  3. Select Split Initialization from Declaration from the menu.

After execution, the Refactoring moves the variable initialization to the separate statement.

double a;
a = 1.42;
See Also