Configuration

Night mode

Indentation

Java Basics Course

Engineers From These Top Companies and Universities Trust EXLskills

1M+ Professionals | 100+ Institutions

This is the EXLskills free and open-source Java Basics Course. It guides learners via explanation, demonstration, and thorough practice, from no more than a basic understanding of Java, to a moderate level of essential coding proficiency.

Is this course FREE?

Yes, this a 100% free course that you can contribute to on GitHub here!

Have more questions?

Basic Syntax

Indentation

A new Java programmer must master the concept of "indentation" in Java. Indentation is used to make our code readable to other users, easier to edit, display how the braces match up and show the logic of the program in an organized fashion. Please look at the example below to see how indentation of the if-else statement makes it easy to see what is happening. Keep in mind, we will cover if-else statements later in the course.

The goal of indentation is to show the logic of our program. Keeping indentation consistent throughout a program is essential. For statements inside a left and right brace, increase the indenting by two spaces. When another pair of braces is nested inside those braces, increase the indentation by another two spaces. It is a good idea to line up the braces vertically. Keep in mind that the function of indentation is to make the program more readable and understandable, which saves an immense amount of time when editing or refining your code.