The data type is determined by three components:
- a set of values or objects;
- a set of operations that can be applied to all values in a set;
- presentation of data determining their storage.
What are the data types in Java?
The programming language contains some predefined built-in types and allows programmers to define their own custom ones.
In Java, data types are divided into primitive and referential.
“Primitive” means that its further division is impossible. To expand or change its programming language does not allow. This data type is described by primitive and other user types.
A variable of primitive type contains a value, and a reference one contains the address of the object in memory.
Java language. Data Types: Time and Date
Compound data is divided into classes, interfaces, and arrays. The members of the interface type are abstract methods and constants. In Java, date and time data types are specified by the Date () constructor:
.
Java. : String
, Java, ( ).
String- : String str.
, new. , String «»:
? -, , str . . String «» ( ) str.
Java , , . . :
- String str1;
- String str2;
- str1 = new String ("");
- str2 = str1;
null, . .
String new. , . , . . , , String. new :
Java – byte, short, int, long, char, float, double boolean. : . .
Java , . : byte, short, int, long char.
Int
Int 32- . 32 . – -2147483648 2147483647 (-231 231 - 1). . , 10, -200, 0, 30, 19 int. int:
, , .
, , , . 0 00 – .
int 0x 0x, :
Int- 0b 0B:
Long
64- . , int. long – -263 263- 1. .
Java int long, L l.
, .
long- long, Java , ; .
int , long, int- long. int. :
Byte
Byte 8- . - -128 127 (-27 27 - 1). , Java. , , -128 127, . int long, byte- . byte- int-, .
, Java .
, int-, , int, . .
Short
16- . – -32768 32767 ( -215 215 - 1).
, , , . Short- , int short. byte- . int long short- , byte.
Char
Char 16- , . , . – 0 65535, . char :
: char C1 = 'A'. , char-, . , . String , , , .
, , . 8: ‘\n’, ‘\r’, ‘\f’, ‘\b’, ‘\t’, ‘\\’, ‘\”’, ‘\’’.
- '\uxxxx', \u ( , u) , . , 'A' 65 41 . , '\u0041'.
'\nnn', n – (0-7). – '\000' '\377', 3778 25510. 0 255, . -, , 1, 2 3 : '\n', '\nn' '\nnn'.
Boolean : true () false (). . . Java boolean – Java- .
Java
, , . , , «».
Java 32 . IEEE 754, , , , 1,4 10-45 3,4 1038, , .
, f F, float-. . :
- float f1 = 3.25F;
- float f2 = 32.5E-1F;
- float f3= 0.325E + 1F.
: +0.0F ( 0.0F) -0.0F. . , : . (, 0.0F 0.0F) NaN.
double 64 . 4,9 10-324 1,7 10308.
. d D, , 19.27d. .