Saturday, January 27, 2018

Java Data Types



Definition : Data type is the classification of the type of data , which can be used used in your programs as per the functionality .

Here java supports explicit declaration of data types , that is data type should be initialized before used as variable.

Syntax : data_type variable_name ;

data_type variable_name = value ;

Example :

int testing ;

int testing =100;

Here we have two types of data types ,

         1) Primitive Data Type
         2) Non primitive Data Type

Now we can see this in detail.

Primitive Data Type :

           1) Integer Types :

                     1)  byte - 8 bits(byte a = 100)
                     2)  short - 16 bits(short a = 100
                     3)  int - 32 bits(int a = 100)
                     4)  long - 64 bits(long a = 100000L)

           2) Rational Types :

                     1)  float - 32 bits(float a = 1.2)
                     2)  double - 64 bits(double a = 12.3456)

           3) Characters

                     1)  char -16 bits(char a = 'Z')

           4) Conditional

                     1) boolean - undefined (boolean a = true)

Non Primitive Data Type(Referenced Data Type):

             Objects and Arrays are the Non Primitive Data Types . And here Referenced
             Data Type are not "Passed by Value" and it is "Passed by Reference".

             Button b = new Button("OK")

Regards,

A M Balaji

No comments:

Post a Comment