Comments Whitespaces And Separators In Java

We have already studied that anything that has been entered as a comment is ignored by the compiler. Comments are useful to explain the operation of the program to anyone who is reading it. Java supports three types of comments.

Comments :

Multiline comments :

These begin with a /* and end with */. Anything that is written between these two comments symbols is a comment and is ignored by the compiler. As the name suggests, these comments can be several lines long.

Single line comments :

These begin with the symbol // and end at the end of line. Such types of comments do not have an ending symbol. Documentation comments : These begin with /** and end with */. This type of comment is used to produce and HTML file that documents the program. We shall not attempt to study this in detail.

White spaces :

Java is a free form language which means that there are no specific indentation rules while writing programs. However, note that there has to be at least one whitespace character between each token, which has not been delineated by an operator or a separator. A whitespace can be a space, a tab or a newline.

Separators :

Java uses the following separators :

  • ; to terminate a statement
  • , to separate consecutive identifiers in declaring variables. Also used inside a for statement to chain statements
  • . to separate package names from subpackages and classes, to separate a variable or a method from a reference variable.
  • () used to contain a list of parameters in a method definition as well as invocation. Also used for defining precedence in expressions, and surrounding cast types. Also used for containing expressions in control statements.
  • { } used to define blocks of code, for classes, methods and local scopes, also used to contain values of automatically initialised arrays.
  • [ ] used to declare array types. Also used when dereferencing array values.
#comments_in_java #whitespaces_in_java #separators_in_java #Multiline_comments_in_java #Single_line_comments_in_java

(New page will open, for Comment)

Not yet commented...