Saturday, June 8, 2019

DATA TYPES - JAVA PROGRAMMING

Anu K Joy


In this blog, you learn the data types available in Java programming language.




In Java program, you cannot even declare a variable without specifying its data type.The data type specifies the size and type of values that can be stored in an identifier. 


There are two types of data types in java :

1. Primitive data types

2. Non-Primitive data types



Primitive Data Types




There are 8 primitive data types in java 

Integer Data Types


  • Integer  - Represents integers using byte, short, int and long.

    byte data type    



            

short data type




Int data type



Long data type



Note :  

             If you need to store a small data, you must use the byte data type and if you use any other data types other than byte, it allocates extra memory space and leads to increase in execution time.


Floating- Point Data Types


  • Floating - Represents Fractional numbers...float and double data types.



Note :

  •  you should end the value with an "f" - Float data type
  • you should end the value with an "d"- Double data type           
The float data type can represent a maximum of 7 digits after decimal while, the double data type can represent 15 digits.


Character Data Types


  • Character - Represents char.
  • An example of char data type is,
                        char dis = 'A';

Boolean Data Types



  • Boolean - Represents two logical values denoted by true or false.
  • Example is,
                                  boolean x = true;


Non Primitive Data Types



  • Sometimes called "reference variables," or "object references. Because, they refer to objects
  • Examples of non-primitive data types are Strings, Arrays, Classes, Interface etc..
we will learn more in detail about Data types in Java programming in coming blog.


Blogger
SEO Analyst
Digital Marketing Consultant


You can also visit my blogs ; 


OOP CONCEPTS - JAVA PROGRAMMING


No comments:

Post a Comment

If else statement in java ( with examples) - Java World

In this article, you will learn to use two selection statements: if and if else to the statements which alter the flow of  your program’s ...