Data Type

Data Types in Java

  •  

Java Primitive Data Types:

 

Java Primitive Data Types Chart:

Byte Data Type:

 

Example:
 
Output:

num1= 120

num2= -127

Explanation:
  •  
Short Data Type:
Example:
 
Output:
36832
Explanation:
  •  
Int Data Type:
Example:
 
Output:

secondNumber = 27

firstNumber = 12333468

Explanation:

 

Long Data Type:
Example:
 
Output:
Result is: 23573908845233
Explanation:

 

Float Data Type:
Example:
 
Output:
total: 834.98
Explanation:
Double Data Type:
Example:
 
Output:
salary is: 29.99
Explanation:
Char Data Type:
Example:
 
Output:

the value of ch1 and ch2

R H

Explanation:
Boolean Data Type:
Example:
 
Output:

is java fun? true

is java hard? false

Explanation:
  •  

Java Non-Primitive Data Types:

 

Common examples of non-primitive data types:

 

Example:
 
Output:

1 2 3 4 5

Hello, Java

Explanation:
Visited 1 times, 1 visit(s) today

Comments are closed.

Close