Page 92 - 2617_JSSPS_C-7
P. 92

double: The double data type is a double-precision 64-bit IEEE 754 floating point or 8 bytes. For
                 decimal values, this data type is generally the default choice. The double data type can store fractional
                 numbers from 1.7e−308 to 1.7e+308, i.e., values up to 16 decimal digits. Note that you may end the
                 value with a "d".

                             Type                  Size            Default value              Example
                      float                4 bytes               0.0f                 float a=10.67f;

                      double               8 bytes               0.0 or 0.0d          double b=1234.87674;


                      Note: The IEEE Standard for Floating-Point Arithmetic (IEEE 754) is a technical standard for floating-
                      point arithmetic established in 1985 by the Institute of Electrical and Electronics Engineers (IEEE).


              Char Type
              It stores character constants in the memory. The char data type is a single 16-bit Unicode character. It
              assumes a size of 2 bytes, but basically it can hold only a single character because char stores Unicode
              character sets. It has a minimum value of ‘\u0000’ (or 0) and a maximum value of ‘\uffff’ (65,535).

                                Type                  Size            Default value           Example
                        char                  2 bytes              \u0000                char c='a';
                                                                                         char d= '\u0041';

              Java uses Unicode system not ASCII code system and to represent Unicode system 8 bits is not enough
              to represent all characters so java uses 16 bits or 2 bytes for characters.

              Boolean Type

              The boolean data type is used to store only two possible values: true and false. This data type is used
              for simple flags that track true/false conditions. The boolean data type specifies one bit of information.

                         Type               Size         Default value       Range of values         Example
                                                                           that can be stored
                   boolean           1 bit              false              true or false         boolean a=true;


                      Note:  1. Integer type and Float type are Numeric data types.
                             2. Character type and Boolean type are Non-numeric Data types.


              Non-Primitive Data Type

              They are also called Reference Data Types or Composite Data types. They contain a memory address
              of variable value because the reference types won’t store the variable value directly in memory. They
              are defined by the programmer according to the requirement of the program. Different types of Non-
              Primitive data types are strings, objects, arrays and interfaces.

              Difference between Primitive Data Type and Non-Primitive Data Type


                               Primitive Data Type                           Non-Primitive Data Type
                   They are built-in data types.                   They are used defined data types.




                        Premium Edition-VII
                 90
   87   88   89   90   91   92   93   94   95   96   97