List of Data Types in Java
Java

List of Data Types | in Java Programming Language

List of Data Types in JAVA Programing Language.

Now you can learn the List of Data Types, In this section, you can easily enhance your knowledge about data types.

What are the data types?

In just simple words the data types refer to a container to store some specific type of values as an example a cargo ship is made to carry cargos, a passenger ship is used to carry a passenger, a destroyer ship is used to carry weapons etc.which means we have different ships to carry different types of things. Just same as we have different data type to store different type of values, the values can be an integer, a character, a floating point (decimal numbers), a result as true or false, etc.

The list of data types can be categorized into two parts-:

List of Data Types
List of Data Types
  • Primitive Data Types
  • Non-primitive Data Types

Primitive:

List of Data Types in Java

Byte: The byte is a data type to store small integer values as it takes 8-bit size in memory. Its range is from -128 to +127. Its default value is 0(zero). A byte is four times smaller than int.

Short: Short data type is also used to store integer values those are greater than a byte, it takes 16-bit size in memory. Its range is -32768 to +32767.its default value is 0(zero).

Int: int keyword is used to store integer values those are out of the range of short, it takes 32bit size in memory. Its range is -2,147,483,648 to +2,147,483,647.its default value is 0(zero).

Note:- Int is the default datatype for integral values, if you use a number without a datatype by default it is considered as in int form by the JVM.

Long: long keyword is used to store integral values those are much larger than the capacity of int. it takes 64bit size in memory. Its range is -9,223,372,036,854,775,808 to +9,223,372,036,854,775,807. Its default value is 0(zero).

Char: char data type is used to store a character; the char is a single 16bit Unicode character. It ranges from 0 to 65535. Its default value is \u000 which means by default it stores “null”.

Float: float keyword is used to store decimal values, the numbers which include a decimal part, it takes 32bit size in memory.  Its range is -1016 to +1016. Its default value is 0.0f.

Double: double keyword is used to store large decimal number, it takes 64bit size in memory. It ranges from -10106 to +10106. Its default value is 0.0f.

  • When it comes to decimal part if the number is in decimal form with no data type, by default the JVM consider it as double.

Boolean: Boolean keyword is used to represent one bit of data. A Boolean keyword has only two values: true and false. This is used to track true or false, and holds the default value ‘false’.

 

Non-primitive

List of Data Types in Java

Class: A class in JAVA refers to a blueprint in which objects are to be created. When it comes to having a class as a data type it refers to taking a class type variable i.e. we write the name of class <space> and a name or any variable. This is called creating a reference of class type. (will discuss it later in detail)

String: A string keyword is used to define a string as an example “how was the day?” the string is immutable i.e. it cannot be modified. A string is a sequence of Unicode characters where each character is of 16bit.

The string is a class so we need to write the string as ‘String’ (as told earlier that classes are written with the first character as capital)

Array: In simple words array refers to a container able to take multiple inputs of the same type. In other words, an array is a group of similar type of data, which might be all integer type, all float types, all character type etc. array doesn’t work by self it needs another data type with him to make itself functional. Example- int arr[];

Enum: Enum is used to store unique data values or unique data set.

What is a unique data set?

Unique data set refers to those data which are unique or say which cannot be changed.

For example:- the name of days like Sunday, Monday, Tuesday etc, or the name of the months like January, February, March, April, etc.

Important key points-:

List of Data Types in Java
List of Data Types in Java

{Byte, short, int, long} these belong to the same family, which means they all stores only integral value.

{Float, double} these belong to another family which only holds values those have decimal part with it.

List of Data Types in Java

Rohit Verma
You Know Who I am

Leave a Reply