Wednesday, 6 May 2015

Separators

Separators are used to inform the Java compiler of how things are grouped in the code. For example, items in a list are separated by commas much like lists of items in a sentence. The most commonly used separator in Java is the semicolon. As you have seen, it is used to terminate statements.


Symbol
Name
Purpose
;
Semicolon
Terminates statements.
,
Comma
Separates consecutive identifiers in a variable
declaration.
Also used to chain statements together inside a for statement.
{ }
Braces
Used to contain the values of automatically initialized arrays.
Also used to define a block of code, for classes, methods, and local scopes.
( )
Parentheses
Used to contain lists of parameters in method definition and invocation.
Also used for defining precedence in expressions, containing expressions in control statements.
Also used for surrounding cast types.
[ ]
Brackets
Used to declare array types.
Also used when differencing array values.
.
Period
Used to separate package names from sub packages and classes Also used to separate a variable or method from a reference variable.




If you know anyone who has started learning Java, why not help them out! Just share this post with them. Thanks for studying today!...

No comments:

Post a Comment