Java Datatypes

Datatypes are used to identify the type of data or which allocates the sufficient memory space for the varables. These Datatypes are classified into following types:
  • Primitive Datatypes
  • Derived Datatypes
  • Userdefined Datatypes
  • Primitive Datatypes:

    Primitive datatypes are used to store the single value at a time
    Example:int x=12;
    int y=12,13;(invalid) These Primitive datatypes are classified into following types
  • Integer datatype
  • Floating point datatype
  • Character datatype
  • Boolean datatype
  • Note: In C-language character datatype occupies one byte of memory because it supports ASCII code(American Standard for Information Interchange ).It contains 256 characters only.So character datatype occupies one byte of memory.
    In java language character datatype occupies two byte of memory because it supports UNI Code(Universal Coding System).It contains 18 international languages.each language contains their own alphabets and symbols and characters.Each characters contains one unique value.So java language character datatype occupies 2 bytes of memory

    Derived Datatypes:

    These are used to store the morethan one value similar type
    Example: Arrays
    int marks[]={12,12,12,12,12,12}

    Userdefined Datatypes:

    These are used to store the morethan one value dissimilar type
    Example: class
    class Demo
    {
    int x;
    float y;
    char z;
    }