The requested page is not available for the requested platform. You are viewing the content for Default platform.

Remove Redundant Assignment

Purpose

Removes the initialization of a variable if it is initialized with the default value.

Availability

Available when the caret is on the name of a field in its declaration, provided that the field is initialized with the default value.

Usage

  1. Place the caret on the name of a field in its declaration.

    Note

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

    private int sum = 0;
    
  2. Use the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions Menu.
  3. Select Remove Redundant Assignment from the menu.

After execution, the Refactoring removes the assignment, which does not change code behavior.

private int sum;
See Also