Keyword, Identifiers, Comment

Keyword

In a computer language, keywords are reserved word for particular uses.

Identifiers

Identifiers are words which you shoud entitle in your code.

Rules for Creating Java Identifier

  1. Begin with a alphabet character
  2. White space is not permitted.
  3. Special Characters are not allowed excpet the `$' and the underscore `_'
  4. Java keyword is not permitted.

Naming Conventions

  1. Class names should be nouns which start with an uppercase letter, in mixed case with the first letter of each internal word capitalized. (ex, BankAccount)
  2. Method names should be verbs which start with a lowercase letter, in mixed case with the first letter of each internal word capitalized. (ex, getName())
  3. Variable names should be nouns which start with a lowercase letter, in mixed case with the first letter of each internal word capitalized. Variable names should not start with underline _ or dollar sign $ characters.(ex, accountNo)
  4. Constant names should be all uppercase with words separated by underscores ("_"). (ex, MAX_BALANCE)

Conventions Example

package net.java_school.bank;
/*
Only package name permit dot(.). 
Domain name is java-school.net but dash(-) is not permited.
*/
public class BankAccount {
	private String accountNo; 
	private long balance;
	
	public String getAccountNo() { 
		return accountNo;
	}
	
	public void setAccountNo(String accountNo) { 
		this.accountNo = accountNo;
	}

	public long getBalance() { 
		return balance;
	}
}

Comment

Comments are text which added with the purpose of making the source code easier to understand by a programmer. They are generally ignored by compilers.

The Java language supports three kinds of comments.

// text

The compiler ignores everything from // to the end of the line.

/* text */

The compiler ignores everything from /* to */.

/** documentation */

This indicates a documentation comment (doc comment, for short). The compiler ignores this kind of comment, just like it ignores comments that use /* and */. The JDK javadoc tool uses doc comments when preparing automatically generated documentation.