Monday, August 1, 2011

Basic Java Data Types

Primitive Data Types :
They are variables which are built into the system. Note that they are not objects.
Having to declare a variable of a specific primitive data types it would always hold the value of the data type. For example, if you were to declare a as a float, a would always be holding a float value.There's a list of eight independent primitive data types in java shown in table below.



























































































































































































































































































































































Keyword












Description












Size



byte



Byte-size
integer












8-bit












short












Short
integer












16-bit












int












Integer












32-bit












long












Long
integer












64-bit












char












Single
character












16-bit












float












Single-precision
floating point












32-bit












double












Double-precision
floating point












64-bit












boolean












True
or false












1-bit




Literals :
Literals specifies a specific data value. You can easiily manipulate the datas - whatever things you assign to a variable that is what you get. For example, 8 is typically an int value. However you can assign this as a double and it would be treated as a double.
































































































































































































Literal









Data Type









27, 027,0x1c









int









100L









long









45.0D , 27.0e3









double









99.0F









float









'B'









char









true /false









boolean









null









null object reference



Mathematical Operators:














































Operator




Description




+




Addition




-




Subtraction




*




Multiplication




/




Division




%




Modulus (division remainder)





(Note :

- Modulus operator works by dividing the number on the left side by the number on the right side evenly and giving the remainder. For example; if you were to divide 9 by 2 , it gives you the remainder 1

-Just like mathematics,operator precedence takes place whenever you use these mathematical operators. It determines the order in which operations are applied to numbers.(eg: *,/,% have precedence over + and -)

No comments:

Post a Comment