# How To Indent Your Code

Indentations are responsible for making your code easy to read and understand. Indenting your code is always best practice as it helps to show the overall structure of your code.

![Karel indentation gif](https://3899603656-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4CE_DjWtTxVmIYccGI%2F-M4CEbFz20voXskDd956%2F-M4CF5Uw3plJIo_Kc9yu%2Fkarel_indentations_ex.gif?generation=1586139022630107\&alt=media)

## Indenting Your Code

A general rule for Java is to _**always**_ place brackets on their own lines, and indent the code within the brackets. Here is an example for you to reference:

```
// Notice how the brackets are on new lines and the code within is indented.
public void run()
{  
    move();
    turnLeft();
    move();
}
```

You apply the same rule for indentations when using nested control structures. Consider this example:

```
// Notice how the brackets are on new lines and the code within is indented.
public void run() 
{
    while(ballsPresent())
    {
        if(frontIsClear())
        {
            move();
        }
    }
}
```
