Saturday, 13 May 2017

JP - Naming Conversion ~ foundjava

Naming Conversion of Java

Sun micro system was given following conversions by declaring class, variable, method etc. So that it is highly recommended to follow this conversion while writing real time code.

Why Using naming Conversion

Different Java programmers can have different styles and approaches to write program. By using standard Java naming conventions they make their code easier to read for themselves and for other programmers. Readability of Java code is important because it means less time is spent trying to figure out what the code does, and leaving more time to fix or modify it.
1. Every package name should exist a lower case latter.

Example

package student;  // creating package

import java.lang;  // import package
2. First letter of every word of class name or interface name should exists in upper case.

Example

class StudentDetails
 {
  .....
  .....
 }
interface FacultyDetail
 {
  .....
  .....
 }
3. Every constant value should exists in upper case latter. It is containing more than one word than it should be separated with underscore (-).

Example

class  Student
 {
 final   String  COLLEGE_NAME="abcd";
  ....
  .... 
 }
Note: if any variable is preceded by final keyword is known as constant value.

Example

class  Student
 {
 Final String Student_name="abcd";
 }
While declaring variable name, method, object reference the first letter of first word should be exits in lower case but from the second words onward the first letter should exists in upper case.

Example

class  Student
{
String  StudentName="xyz";
void  instantStudentDetails();
{
  ....
  .... 
}
Student  final

CamelCase in java naming conventions

camelcase
Java follows camelcase syntax for naming the class, interface, method and variable. 
According to CamelCase if name is combined with two words, second word will start with uppercase letter always. General Example studentName, customerAccount. In term of java programming e.g. actionPerformed(), firstName, ActionEvent, ActionListener etc.

No comments:

Post a Comment