Tuesday, 27 August 2013

Variable and Datatype In Java

Variable mean varying value.Variable carry small amount of portion of memory and its value can be change during throughout program execution.Variable Name are the actually name of the memory unit.
Consider variable is a basket which carry something and something is a value.
Variable can be store integers value,character value, floating value, yes/no value ; these are called datatype of variable.





Datatype are the type of data can be storing in the variable.There are 8 type of datatype

  1. Boolean (Yes/No) (1 Bit of Memory)
  2. byte (Small Integer Value) (1 Byte of Memory)
  3. short( Small but larger integer than byte value) (2 Byte of Memory)
  4. int (Integer Value : +1,-1) (4 Byte of Memory)
  5. long (Large Integer Value) (8 Byte of Memory)
  6. float(Floating value ) (4 Byte of Memory)
  7. double(Large Floating value) (8 Byte of Memory)
  8. char (Character Value) (2 Byte of Memory)


Syntax of Using Variable with Datatype

DataType variableName;
variableName=value;

Example

int number;
number=12;


No comments:

Post a Comment