Monday, 24 March 2014

Java Naming conventions

Posted By: Unknown - Monday, March 24, 2014

naming convention is a rule to follow as you decide what to name your identifiers e.g. class, package, variable, constant, method etc.
But, it is not forced to follow. So, it is known as convention not rule.

Advantage of naming conventions in java

By using standard Java naming conventions, you make your code easier to read for yourself and for other programmers. Readability of Java program is very important. It indicates that less time is spent to figure out what the code does.


NameConvention
class nameshould start with uppercase letter and be a noun e.g. String, Color, Button, System, Thread etc.
interface nameshould start with uppercase letter and be an adjective e.g. Runnable, Remote, ActionListener etc.
method nameshould start with lowercase letter and be a verb e.g. actionPerformed(), main(), print(), println() etc.
variable nameshould start with lowercase letter e.g. firstName, orderNumber etc.
package nameshould be in lowercase letter e.g. java, lang, sql, util etc.
constants nameshould be in uppercase letter. e.g. RED, YELLOW, MAX_PRIORITY etc.

Understanding CamelCase in java naming conventions

Java follows camelcase syntax for naming the class, interface, method and variable.
If name is combined with two words, second word will start with uppercase letter always e.g. actionPerformed(), firstName, ActionEvent, ActionListener etc.

0 comments:

Post a Comment

this blog is helpful or not

International

Auto News

Translate

Pages

Popular Posts

Popular Posts

Designed By Templatezy / Sb Game Hacker Apk / MyBloggerThemes