English

Explain the usage of the following special symbol in Java: {}(braces)

Advertisements

Question

Explain the usage of the following special symbol in Java:

{}(braces)

Explain
Advertisements

Solution

The braces {} are used in Java to define a block of code. They mark the beginning and end of classes, methods, loops, and conditional statements. The opening brace { indicates the start of a block, while the closing brace } indicates its end. They help group multiple statements together so that they are treated as a single block.

Example:

if (a > b) 
{
    System.out.println("a is greater");
}
shaalaa.com
  Is there an error in this question or solution?
Chapter 6: Variables and Expressions - EXERCISE [Page 135]

APPEARS IN

Dheeraj Mehrotra Computer Science [English] Class 12
Chapter 6 Variables and Expressions
EXERCISE | Q 60. (c) | Page 135
Advertisements
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×