Data Types in Java

Data Types:

Data types, containers and values: In order to store a certain value we need to create a container with a descriptive name of the data that we want to store in. Container casted with a data type operator, followed by container name and assigned with a value.

Data TypeDefault Value (for fields)
String (or any object)null

eg, Boolean data type:

Boolean container = true; or Boolean container = false; or Boolean container = 1; or Boolean container = 0; The boolean data type has only two possible values: true and false. It represents one bit of information and the default value is false.

eg, String data type:

String container = “value”; String: is the way to cast a text data container in programing languages. Identifier, variable, field or property is the container. This is not equal sign as we know it in mathematics but it is here called the assignment operator. Double or single quotes are used for string or alphanumeric datas or values.

eg, Integer data type:

int container = 0; It is a 32-bit signed two’s complement integer and the default value is 0. No double or single quote is used to store an integer value.

eg, Float data type:

Float container = 3.65f; The float data type is a 32-bit single-precision. And it has the default value of 0.0f used to store memory in large arrays of floating point numbers.

eg, Double data type:

Double container = 123.4; The double data type is a 64-bit double-precision. And it has the default value of 0.0d used to store decimal values.