June 2018
Beginner
722 pages
18h 47m
English
You have seen the separators {} (braces) around the class:
class SomeClass { //class body with code}
You have also seen braces around method bodies:
void someMethod(int i){ //... if(i == 2){ //block of code } else { //another block of code } ...}
The braces are also used to denote a block of code in control-flow statements (see Chapter 10, Control Flow Statements):
void someMethod(int i){ //... if(i == 2){ //block of code } else { //another block of code } ...}
And they are used to initialize arrays (see the Arrays section):
int[] myArray = {2,3,5};
There are also a few other rarely used constructs where braces are used.
Read now
Unlock full access