➧What is Data-type :
If data is considered, then the whole world is full of data. Data is also very important in real world. For example, every person has his own data, such as his name, his mobile number, his address proof, all this is his data.
Data is stored somewhere in some form and this data is in different formats, such as the person's name is the data of a String Type and its mobile number is the data of an Integer Type. There are several categories of data that are called this type of data. The type of data is kept in several categories. Because of being in different categories, define the data.
Data type is a fundamental concept of programming language, by which Programmer defines the data type in its source program, and tells the compiler what type of data it wants to store. Understanding the data type defined by the programmer as a compiler works two -
- First, he creates space for that data type in memory.
- The second is that at the same time, he gives that name to the reserve memory, which is its address.
One thing I can tell you is also that there is also a limite of all data types that the programmer has to give. If the programmer stores more value than that Limite, then there is no value store on it, so all the data types have been made Limite.
➧Types of Data-Type :
The data type in Java is divided into two parts, so let's know what their are two types-
1. Primitive Type Data.
2. Non-Primitive Type Data.
Primitive Type Data also has its own types, primitive data type comes in 8 kinds of data types which are as follows -
➧Pimitive Type Data :
- int ( Integer )
- long ( Long Integer )
- float ( Floating Value )
- double ( Long Floating Value )
- byte ( Byte Code Value )
- short ( Short Value )
- char ( Character Value )
- Boolean ( Boolean Value )
1. int ( Integer Value ) :
- This data type is for integer value.
- In case of size, it is larger than data type (short, byte).
- By default, its value is 0 (zero).
- 32-bit is its size.
- It only holds the Integer value itself.
- It neglects the float value.
Source Code :
OUTPUT : 16
2. long ( Long integer ) :
- This is the largest data type of data type integer.
- In case of size, this is the largest data type (int, short, byte).
- By default, its value is 0L (zero L).
- Because it is the largest in size, 64-bit is its size.
- It also holds the value of the integer type only.
- It also does not show float value.
Source Code :
OUTPUT : 1608
3. float ( floatoating value ) :
- This is the small data type of data type float type.
- In case of size it is smaller than the data type (double).
- By default, its value is 0.0L (zero point zero L).
- Because it is smaller than double in size so it is 32-bit.
- It only holds the value of float type.
- It also works with int value. But its value shows in the float.
Source Code :
OUTPUT : 16.08
4. double ( Long floatoating value ) :
- This data type is a large data type of data type float.
- In case of size it is larger than the data type (float).
- By default its value is 0.0d (zero point zero di).
- Because this size is larger than float, so it is 64-bit.
- It also holds the value of only float type. But it stores big value more than the float.
- It also works with int value. But its value shows up in the float.
- The difference between the size of the two is the same as the bank work.
Source Code :
OUTPUT : 16.081997
5. byte ( byte value ) :
- This is the smallest data type of data type integer datatype.
- In case of size it is smaller than data type (int, short, long).
- By default, its value is 0 (zero).
- Because this is the smallest data type in size, so it is of 8-bit i.e. 1 byte.
- It also holds the value of the integer type only.
- It does not work with float value.
Source Code :
OUTPUT : 2624
6. short ( Short data value ) :
- This is the data type of the medeum size of the data type integer type.
- In case of size, this data type is bigger by byte and int is smaller than long.
- By default, its value is 0 (zero).
- Because this size is larger than byte and is smaller than int and long hence it is 16-bit that is 2-byte.
- It only holds the value of the integer type.
- It can not work with float value. Because it's the data type of an integer type.
Source Code :
OUTPUT : 12345
7. char ( String Value ) :
- This works on data type alphabets i.e. charactors.
- In case of size, this data type is 16-bit, that is 2-byte.
- It holds only one charactor.
- It does not work with other Value.
- Singh Quotes ('') is used to define this.
Source Code :
OUTPUT : L
8. boolean ( true/false value ) :
- It is used to declare data type using boolean keyword.
- It returns true or false value to the output.
- By default, its value is false.
- Because it is smaller than double in size so it is 32-bit.
- It only holds the value of float type.
- It does not work with int, float, double or any other value.
Source Code :
OUTPUT : true
* Check Default Value by Source Code :
Source Code :
➧Non - Primitive Data Type :
1. String
2. ArrayLike this post, If you find Topic useful in this post, so share it with your friends and colleagues on Facebook, Twitter, whatsapp and Google Plus.
Thank You !
Note - Fore more Topics are available in www.kptechsolution.com.
0 Comments