In Java, semicolons are used to declare the end of a statement. Typically, semicolons are placed at the end of the line.

For example, when declaring a new variable, you place the semicolon to denote the end of your statement:

int a = 5;

When calling a function, you also use a semicolon.

print("hello");

You may also see the semicolon after statements such as the return statement:

int addNums(int a, int b) {
return a + b;
}

If-statements and loops use the curly braces instead, as they need to wrap multiple lines of code within them, as shown below:

if (a == b) {
// Do something
} else {
// Do something else
}