Sunday, September 12, 2010

Variable Types

Variable Types

Since Variables stand for items that the program is manipulating
or playing with,  such as:
                        whole numbers       (small  normal   large)
                        fractional numbers        (small   large)
                        single characters
                        groups of characters as a unit
                         true / false conditions
 it is only logical to assume that JAVA gives the programmer  the

 capability to declare and use Variables that can hold each of the

above data types.  Remember that values ( or data ) being put into
Variables is the heart or basis of programming. 

Variables MUST be declared before they can be used in a program.

Common Variable types are as follows:
   short                     ... small integers
   int                          ... normal integers
   long                       ... big integers
   float                       ... small fractional numbers
   double                   ... big fractional numbers 
   char                       ... single character values   e.g.,     M    or   F
   string                     ... groups of characters viewed as a unit
   Boolean                 ... logical  TRUE  or  FALSE  values 

In object oriented and more sophisticated programs today, the
programmer can declare his or her own data type ( later )

Specifics concerning Java Data TYpes
NUMERIC (all numbers are signed)

short integer (16 bit number) --> i.e. 32,768
int integer (32 bit number) --> i.e. 2 billion or 2 x 109
long integer (64 bit number) --> i.e. 9 x 1018
float real (32 bit decimal) --> i.e. 1.4 x 10-45 to 3.4 x 1038
double real (64 bit decimal) --> i.e. 4.9 x 10-324 to 1.7 x 10308
  CHARACTER / STRING

char a unicode (2-byte) char
the String class handles multi-character strings (strings are unicode, as well). Strings are said to be immutable: updates to a String cause the new string to be created in memory (and pointed to by the String class). However the old string is not actually "updated", rather, its reference is lost (and it becomes available for garbage collection).  
BOOLEAN

boolean (with values true, false)  
DATE

the Date class measures the milliseconds since Jan 1, 1970 and provides supporting functions to interpret and manipulate date/times  
ARRAYS

arrays hold multiple instances of a data type or object

No comments:

Post a Comment