Open In App

Separators in Java

Be it a programmer who is unaware of this concept but is indulging in every program. Separators help us defining the structure of a program. In Java, There are few characters used as separators. The most commonly used separator in java is a semicolon(;). Let us explore more with the help of an illustration with the “Hello World” program to put more emphasis on separators.

Illustration: Hello World







Observations drawn are as follows:

These separators are pictorially depicted below as follows: 



Symbol Name  Purpose 
( ) Parentheses used to contain a list of parameters in method definition and invocation. also used for defining precedence in expressions in control statements and surrounding cast types  
{ } Braces Used to define a block of code, for classes, methods and local scopes Used to contain the value of automatically initialised array 
[ ] Brackets declares array types and also used when dereferencing array values 
; Semicolon Terminates statements
, Comma Used to separates package names from sub-package and class names and also selects a field or method from an object
. Period separates consecutive identifiers in variable declarations also used to chains statements in the test, expression of a for loop
: Colon Used after labels
Article Tags :