What are data types in Java? - ICSE Java Expert

Breaking

ICSE Java Expert

Learn Java for school

Unordered List

WELCOME

Monday, August 06, 2018

What are data types in Java?


Data Types in Java



Definition:
Data types means the type of data that can be stored in a variable.

Types of data types:
  1. Value-type data types
  2. Reference-type data types


Value Type Data Types

Value type data types store the values. 
Example: int, float. char, boolean etc.

int a = 67; // here int variable a is a value type data type which stores the value 67.

Reference Type Data Types

Reference type data types store the reference of the values. 
Example: String, array, interface, all classes and wrapper classes etc.
String a = "67"; // here String variable a is a reference type data type which stores the reference of the value "67".

Default values for some data types:

Data Type Default Values
byte 0
short 0
int 0
long 0L or 0l
float 0.0f or 0.0F
double 0.0 or 0.0d or 0.0D
char '\u0000'
String (or any object)   null
boolean false

No comments:

Post a Comment