Data Types in Java With Example and Types

.
Data Types in Java With Example 

What is Data Types?

  • Data types are used to represent types of variables and expressions.
  • Data types are used to represent how much memory is allocated for variables.
  • Data types are used to specify the range value of the variable. 

Data types in Java

Syntax of Data Types
The basic syntax of the data type is as follows,

Data types   name of variable = value /literal;

Eg.  int a=10;

int  ->   Data Type
a    ->   Variable name
=    ->  Assignment
10  ->   Constant Value
;    ->   Statement terminator 

Types of Data Types in Java
Data types are divided into two sub-part
  • primitive data type
  • Non-Primitive data type
Primitive data type in Java
In Java primitive data types are used to specify the size and type of variable of value.

There are 8 Primitive data types in Java 
  • Byte
  • Short
  • Int
  • Long
  • Float
  • Double
  • Char
  • boolean
Primitive data types in Java

Non-Primitive data type in Java

In Java Non-primitive data types are also known as reference types because Non-primitive data types refer to objects.

Examples of non-primitive data types
  • Strings
  •  Arrays
  • Classes, 
  • Interface etc.
The important point to remember about Non- primitive data type
  • In Java a non-primitive data type is not pre-define it is created by the Java programmer except string data type
  • In Java, programmers used non-primitive data types to call the method to perform some creation actions.
  • In Java, a non-primitive data type can be null.
  • In Java, a non-primitive data type starts with Upper Case


Byte  Data Type


Short Data Type


Int Data Type


Long Data Type


Float Data Type


Double Data Type

Char Data Type

Boolean Data Type


Hope !!! The above tutorial on data types in Java is helpful for you...

Team,
QA acharya

Post a Comment

0 Comments