Tuesday, April 4, 2017

Java Naming Convention for function name, variable name, class name and constant

There are 3 methods to name an identifier:

Camel case: used to name a function,variable
e.g: int streamJavaMethod() or for variable, arrayBoss;



Pascal case: used to name a class
e.g: class StreamJavaClass()

upper case: used to name constants
e.g.: PIE
Constants
The names of variables declared class constants and of ANSI constants should be all uppercase with words separated by underscores ("_"). (ANSI constants should be avoided, for ease of debugging.)

static final int MIN_WIDTH = 4;

static final int MAX_WIDTH = 999;

static final int GET_THE_CPU = 1;

No comments:

Post a Comment