What is the use of curly brackets in Java? | SoloLearn: Learn to code for FREE!

+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?

5/21/2020 9:45:13 AM

M Y

1 Answer

New Answer

+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.