Java Constants

Constant:

Constant is an identifier whose value can not be changed.In java language these constants are classified into following types
  1. Numerical constants
  2. Character constants
  • Numerical constants:
  • Numerical means numbers .these are classifed into 2 types
    1. Integer constants
    2. Real constants

    1. Integer constants:
    2. Integer constants menas + or - numbers.
      example:
      int x=10;
      int y=-10
    3. Real constants:
    4. Real constants means floating values or decimal values.
      example:
      float x=10.0;
  • Character constants:
  • These are classified into fllowing types
    1. Single character constants
    2. String character constants
    • Single character constants:
    • If any character or symbol or number enclosed with single quotation.
      example:
      char x='a';
      char x='2';
      char x='@';
    • String character constants:
    • Group of characters or symbols or numbers encliosed with double quotation.
      example:
      String s1="abc";
      String s2="@##$";
      String s3="123";