# Invert Boolean

> **TL;DR**
> `Refactor | Invert Boolean`
>
>
>
> This refactoring is also available from [UML Class diagram](class-diagram.html).

The Invert Boolean refactoring lets you change the sense of a Boolean method or variable to the opposite one.

Procedure:

1. Place the caret at the name of the method or variable that you want to refactor.

2. On the main or context menu, select `Refactor | Invert Boolean`.

3. In the dialog that opens, specify the name for the inverted method or variable.

4. [Preview and apply changes](refactoring-source-code.html#changes_preview).

## Example

| Before | After |
| --- | --- |
|     ```JAVA private double a; ... public boolean method() {     if (a > 15 && a < 100) {         a = 5;         return true;     }     return false; } ```    |     ```JAVA private double a; ... public boolean method() {     if (a > 15 && a < 100) {         a = 5;         return false;     }     return true; } ```    |
|     ```JAVA boolean b = true; ... public double method() {     ...     b = false;     ... } ```    |     ```JAVA boolean b = false; ... public double method() {     ...     b = true;     ... } ```    |

## Invert boolean dialog

This dialog appears when you use the Invert boolean refactoring.

| Item | Description |
| --- | --- |
| Name of inverted method/field | Specify the name for the inverted method or field. |

## See also

### Refactoring

[Code refactoring](refactoring-source-code.html)

