Wednesday, August 22, 2012

Primitive Data Types


These are primitive data types use in Java programming, primitive data types are the building blocks for more complicated types. In Java, its primitive types are portable across all computer  flatforms that suppport Java. Unlike some other programming languages, programmers had to write separate versions of programs to support different platforms because the primitive data types were not guaranted to be identical from computer to computer. the value of memory of a specific data types might be different from one machine to another computer. In Java, for example, int values are always 32 bits (4 bytes).

 Information reference: dietel&dietel Java How to Program (Third Editionn)
type                   size in bits              values                                                standard

boolean                   8                       true/false

char                        16                     '\u0000' to '\uFFFF'                       (ISO unicode character set)

byte                        8                      -128 to 127

short                      16                      -32,768 to +32,767

int                          32                     -2,147,483,648
                                                     to 2,147,483,647

long                        64                     -9,223,372,036,854,775,808
                                                     to 9,223,372,036,854,775,808

float                       32                     -3,40292347E+38                       (IEEE 754 floating point)
                                                    to 3,40292347E+38

double                   64                     -1,79769313486231570E+308     (IEEE 754 floating point)
                                                    to 1,79769313486231570E+308

For some related post please read How to declare variables?

No comments:

Post a Comment