Warning: session_start(): open(C:\Windows\temp\sess_bgj1gq6ho4uf60ssa5336j2gj3, O_RDWR) failed: Invalid argument (22) in D:\web\ktbrain\wp-content\plugins\wpforo\wpf-includes\class-notices.php on line 16
Coding Standards-III – ktbrain

Coding Standards-III

White Spaces

White spaces means space characters inserted when the space bar or enter key is pressed on the keyboard. The white spaces in Java code provide readability and better understanding of the code.There are four other types of white spaces in Java: the horizontal tab, the form feed, the carriage return, and the linefeed depending on the Operating System(OS).

The concept of white spaces will be discussed on the basis of the following two aspects:
Blank Lines, Blank Spaces
Blank Lines
The blank lines in Java source code improve readability by arranging the sections of code that are logically related.
Two blank lines are provided between:

  • Sections of a source file.
  • The class and interface definition.

Single blank lines are provided:

  • Between methods.
  • Between the local variable in a method and its first statement.
  • Before a block or a single line comment.
  • Between logical sections within a method to improve readability.

Blank Spaces
Blank space refer to an extra space between two words provided by pressing the space bar key on the keyboard. The blank spaces should be provided under the following conditions.

  1. A keyword followed by a parenthesis should be separated by a space like this
    while (true) {
  2. A blank space should be provided after commas in argument lists, like this
    public String myarg (a1, a2, a2, a4){
  3. All binary operators except ‘.’ should be separated from their operands by spaces. Blank spaces should not separate unary operators, such as minus(-), increment(++), and  so on.
    x += y + z;
    x = (y + z) / (p * q);
  4. The expressions in the for statement should be separated by blank spaces. For exmaple
    for ( i = 0; i < 10; i++) {
  5. Data type of a variable should be followed by a blank space, like
    public void newmethod( int x , int y) {


Java allows to place descriptive comments in your code.This facilitates you in explaining the code and the working of the program with its purpose.
Java supports 3 types of comments

  • A comment of any length with the characters /* and */ like
    /* This application prints out “Hello from Java!”
    Created by: kogent 1/09/08 */.
  • Java also supports one-line comment, using the double slash(//). The Java compiler ignores everything on a line after the // marker  like // single line comment.
  • Finally, Java also supports a documentation comment, which starts with /** and ends with */. This comment is designed to be used with the Javadoc tool, which can create documentsation for automatically. For Example
    /** This application prints out “Welcome To Java!”
    Author: Kavitha*/

    public class App {
    public static void main(String[] args) {
    System.out.println(“Welcome to Java!”); }

One thought on “Coding Standards-III

  • July 22, 2017 at 8:20 am

    Good one. .keep posting java topics


Leave a Reply to Rajesh Cancel reply

Your email address will not be published. Required fields are marked *

Warning: Unknown: open(C:\Windows\temp\sess_bgj1gq6ho4uf60ssa5336j2gj3, O_RDWR) failed: Invalid argument (22) in Unknown on line 0

Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (C:\Windows\temp) in Unknown on line 0