Java Data Types
Data types specify the size of the different values that can be stored in the variables. There are two types of Java data:
- primitive data types: The primitive data types include boolean, char, byte, short, int, long, float, and double.
- non-primitive data types: Data types, including non-primitive classes, interfaces, and arrays.
Java primitive data types
In Java, primitive data types are the basic components of data manipulation. These are the most basic types of data available in the Java language.
There are 8 primitive data types:
- boolean type
- byte of data bytes
- char data
- short data type
- int data type
- long data type
- Float type data
- double data type
Click here to know about->choose java career option
Boolean data type
A Boolean data type declared by the keyword and Boolean can only receive the true or false value:
For example:
isJavaFun boolean = true;
boolean isFishTasty = false;
System.out.println (isJavaFun); // true outputs
System.out.println (isFishTasty); // false outputs
Byte of data bytes
This could put the integer between -128 and 127. It is often used to save memory and when you are sure that the number will be within the limits specified by the data byte type.
The default size of this data type: 1 byte.
Default Values: 0
Short data type
The data type is a short integer of 16 bits of two. The range of values of Na is between -32768 and 32767 (inclusive). The minimum value is -32768 and the maximum value is 32,767. the default is 0
The type of data cottage can also be used to save memory, as the data bytes type. A type of data house is 2 times smaller than an integer.
Example: s = 10,000 hut, hut r = -5,000
Int data type
Int Data Type is a 32-bit add-in with an integer of two. The Na value change is between -2,147,483,648 (-2 ^ 31) to 2147483647 (2 ^ 31 -1) (inclusive). The minimum value is — 2,147,483,648 and the maximum value is 2147483647. The default value is 0.
The Int data type is usually used as the default data types for the integral, except when there is no memory problem.
Example: int a = 100000, int b = -200000
Long data type
The data length type is 64 bits of two integers of complement. The Na value change is between -9.223.372.036.854.775.808 (-2 ^ 63) at 9.223.372.036.854.775.807 (2 ^ 63 -1) (inclusive). The minimum value is — 9.223.372.036.854.775.808 and the maximum value is 9.223.372.036.854.775.807. the default is 0. The type of data that is used when you need a range larger than that provided by int.
Example: a = 100000L very, very b = -200000L
Float data type
Floating data type is a simple 75-bit IEEE 32-bit precision floating point. It’s none. It is recommended to use a float (instead of a double float), if necessary, to save memory on large sets of floating point numbers. The floating data type should not be used for the sake of value, such as currency. the standard is 0.0f.
Examples: float F1 = 234.5f
Double data type
Multiple data types are IEEE 754 dual-precision 64-bit floating point. And the range is unlimited. Various general purpose data types for floating decimal similar. Various types of data must also have been used for the better, such as currency. The standard is 0.0d.
Example: double d1 = 12.3
Char Data type Char
Char data type is a single 16-bit Unicode character. The value range Na is between ‘\ u0000’ (or 0) and ‘\ uffff’ (or 65,535 inclusive) The CHAR data type is used to store the character.
Letter ‘A’ Char: example
Non-primitive data types
No primitive data type called reference type objects see.
The main difference between simple and non-primitive data types is:
• Primitive types are ready for use (would have been) in West Java. non-primitive types that are created by programmers and not defined by Java (except string).
• Non-primitive types can be used to call methods to perform certain operations, while primitive types can not.
• Primitive types always have a value, while the hypothesis may not be primitive.
• A primitive type, preceded by a lowercase letter, while the non-primitive type begins with a capital letter.
• The size of a primitive type according to the type of data, while the non-primitive types have all the same