Symbolic Constants in Java?

Constants  may  appear  repeatedly in number  of places  in the program. Constant  values are assigned  to some names  at   the  beginning  of the program, then the subsequent   use of  these names   in  the  program has the  effect  of  caving  their defined  values  to be  automatically  substituted  in appropriate  points. The  constant  is declared  as  follows:

Syntax : final type  symbolicname= value;
     Eg     final  float     PI  =3.14159;
               final  int  STRENGTH  =100;

Rules :-

symbolic  names take the  some   form  as variable  names. But  they  one written  in capitals  to distance   from variable  names.  This  is only  convention  not a  rule.

After  declaration  of symbolic  constants  they shouldn’t   be  assigned  any other value  with in the  program by using  an  assignment  statement.

For  eg:-    STRENTH  = 200  is  illegal

Symbolic  constants  one  declared  for  types   there  are  not done  in c & c++  where symbolic constants  one defined  using    the  define  statement.


They  can’t be  declared  inside  a  method . they  should be  used  only as class  data members  in  the beginning   of the class.

Related

Write about Jumps in loops in java

Jumps in loops: Break : [jumping of out of a loop] Break is used to come out of a loop, an early exists from a loop can be accomplished by using break statement. The break statement can be use...

Write about Labeled loops in Java

Labeled loops: In java we can give a label to a block of statements a label is any valid java variable name. to give a label to a loop, place it before the loop with a colon(:) at the end. For...

Explain Java Environment ? (or) Java Development Tool Kit ?

Java environment includes a large number of development tools are part of the system known as java development kit is the classes is methods are part of the java standard lib...

Post a Comment

emo-but-icon
:noprob:
:smile:
:shy:
:trope:
:sneered:
:happy:
:escort:
:rapt:
:love:
:heart:
:angry:
:hate:
:sad:
:sigh:
:disappointed:
:cry:
:fear:
:surprise:
:unbelieve:
:shit:
:like:
:dislike:
:clap:
:cuff:
:fist:
:ok:
:file:
:link:
:place:
:contact:

item