When to use Code block

Hello everyone
I am starting my way in Java programming
And one of the things I couldn’t understand ,is the code area.

When do we need to put the {}.
In the example below I have code
I understand that I need to insert {} but I don’t understand why or where

Greetings, and welcome to the forum.

So. Brackets contain code that represent the operations of your program. Use bracket whenever you need to define a class, method, or function. For instance, the “main” method, or your class:

MyClass{

My constructors, fields, getters, setters, instance methods, class methods, inner/nested classes, and my “main” method.

}

If I define a new method, the brackets would be used like this:

Public void myMethod( arguments){ method definition/my code here
}

Finally, think of brackets as an encapsulation or nesting tool, where code, classes, methods, or functions, are encapsulated or nested within other code, like this:

Public void myMethod(arguments){
My code {
More code/another function} //end of inner code
} //end of myMethod()