data type in java

DATA TYPES IN JAVA PART . 9

Data Types in Java

Data types in java under the following categories :

1 :- Primitive Data Types (intrinsic)

2 :- Non Primitive Data Types (Derived)

Primitive Data Types

Primitive Data Types

Java is statically typed i.e. variables must be declared before use.

There are 8 Primitive Data Types supported by Java :

1 :- byte :      A value ranges from -128 to 127

                         Takes 1 byte

                         Default value is 0

2 :- short :    A value ranges from –(216)/2 to (216)/2-1

                         Takes 1 byte

                         Default value is 0

3 :- int :        A  value ranges from -–(232)/2 to (232)/2-1                

                         Takes 2to4 byte

                         Default value is 0

4 :- float :     A  value ranges from

                         Takes 4  byte

                         Default value is 0.0

5 :- long  :    A  value ranges from -–(264)/2 to (264)/2-1                

                         Takes 8  byte

                         Default value is 0

6 :-  double : A  value ranges from

                         Takes 8  byte

                         Default value is 0.0

7  :-  char  : A value ranges from 0 to 6553(216 – 1)

                         Takes 2  byte

                         Default value is

8 :-  Boolean : A value can be true or false                

                          Size depend on  JVM

                          Default value is  false

HOW TO CHOOSE DATA TYPES FOR OUR VARIABLES  :

In order to choose the data type we first we need to find to find the type of data , we want to store. After that, we need to analyze the min and max value we might use.

Non Primitive Data Types :

Non Primitive Data Types

Now Friends If you like this post please tell us how can we help you to provide better knowledge?

If this post is use full for you please share the post with your friends.

Please follow as facebook : www.facebook.com

Please follow as twitter : www.twitter.com

And more information please visit here : www.weindians.in

Please Subscribe on youtube : www.youtube.com

One thought on “DATA TYPES IN JAVA PART . 9

Leave a Reply

Your email address will not be published. Required fields are marked *