Friday, 13 March 2020

Naming Conventions in Java



Java naming conventions are very simple. Here we provide step by step java training. Following are naming conventions rules for followings:


  • Class
  • Interface
  • Method
  • Variable
  • Package
  • Constant
BCA Java Training in Mumbai
Java Training in Kandivali


Class: Class name should be start with the capital letter (Uppercase)  and followed by small letter(Lowercase) and next word first letter should be capital letter (Uppercase), without any white space (no-gap) between words. Write class name in Pascal case.

Example:
public class EmployeeDailyReport
{
  ///Code
}


Java Training in Goregoan
MCA  BCA Java training

Interface: Interface name should be start with capital letter (uppercase) and followed by small letter (lowercase) and next word first letter should be capital letter (Uppercase), without any white space (no-gap) between words. Write interface name in Pascal case.


Example:
interface EmployeeBasicRule
{
  ///Code
}




Step by step training in java
Java Step by Step Training

Method: Method name should start with small letter(lowercase) and with the first letter of next word in capital letter (uppercase). Write method name in Camel Case.

public void getEmployeeNetSalary
{
   //code
}



Java Class, Interface, Package, Constant, Variable Naming Conventions
Java Class, Interface, Package, Constant, Variable Naming Conventions

Variable : For writing variable name you should follow the following rules:

  • Write in very short names.
  • Should not start with underscore or any special characters.
  • Should not start with numeric character.
  • It should start with Character.
  • Don't use reserve keywords in Variable name.
Example:

string FullName




Java Naming Conventions
Java Naming Conventions 

Package: Package name should be write in small letter (lowercase). Package name should be separated with .(dot) . Package name should have main title / department name. Like Sales, Purchase, HR because package is grouping of classes, interfaces.

Example:
package com.Employee.Attendance



Constant in Java YCMOU
Constant in Java YCMOU

Constant: Constant name should be start in capital letter (uppercase). Constant name should be separated with _ (underscore).

Example:
static final int Max_Salary = 45000;







No comments:

Post a Comment