data types

In Java we distinguish many types of data that can be stored in both the number and was floating, characters, strings, and Boolean type. Java is a strict type checking, that is, each object must have a specific type.

The number of Fixed Point are integers, we distinguish the 4 types, due to the amount of occupied space.

byte – 1 byte – range from -128 to 127
short – 2 bytes – range from -32 768 to 32 767
int – 4 bytes – range from -2 147 483 648 2 147 483 647
long – 8 bytes – the range of -2 ^ 63 to (2 ^ 63) -1
The most versatile is the type int, its scope is usually sufficient to perform all operations and at the same time does not occupy much space.

In addition, there is a class curtain, which are object-oriented counterparts simple types. They provide methods by which many routine activities we are always at hand.

Java does not have a type Unsigned (unsigned), the consequence is that exceeding the scope of the type to go negative range.

The next two types represent floating-point numbers, and like integers differ in scope and amount of occupied space, as well as precision

float – 4 bytes – max of about 6-7 decimal place (they have suffix F or f)
double – 8 bytes – max of about 15 decimals (they have suffix D or d)
The integer part of the fraction separated by a dot, not a comma! Please also note that floating point numbers are not suitable for financial calculations where accuracy counts. This is due to the fact that the binary system is not possible to present all the numbers. With the help comes here a special class BigDecimal. There is also a class BigInteger, which is equivalent to the integers and can represent essentially unlimited largest number.

Another type is char, or character and is used to represent a single Unicode character. They can be presented in single quotation marks, using the hexadecimal, or simply quoting the Unicode character in the decimal system – we’ll see about that in the next lesson. In short, you are allowed entry ‘a’ or \ U0000.

There are also special characters that must be preceded by a backslash \:

\ T – tab
\ N – new line
\ R – carriage return
\” – quotation marks
\ ‘- Apostrophe
\\ – Backslash
The last type is a simple boolean. It represents only two values:

true – true
false – false


Close Menu