+ 1

What is the use of curly brackets in Java?

So I just started learning Java and I always get confused by the curly brackets in example code. Are there any rules for it's placement and rules that I should know?

21st May 2020, 9:45 AM
M Y
M Y - avatar
1 Odpowiedź
+ 2
They define a block of code. It could be a method or a class or a static block or an instance initializer block. You must use them with the above mentioned or your code will throw a compile time error.
21st May 2020, 9:50 AM
Avinesh
Avinesh - avatar