Where are static final variables used in java? -


i studying java , wanted know what's usage of static final variables in application designing. please provide examples too.

uses of static final variable :

  1. to define compile time constant value. e.g : integer class defines constant called min_value : public static final int min_value = 0x80000000;
  2. to create non modifiable reference can accessed globally : e.g singleton pattern using public static final reference.

when mark variable defined in class static, shared across instances of class. when mark variable in class final, can initialized once either on same line declaration of variable or in constructor of class. putting both together, member static final variable shared across instances of class, must initialized declared, , cannot modified once declared.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -