All numeric types have a maximum and minimum value they can represent. Only so many bytes are available—this limits numbers.
Classes, final ints. In Java the numeric classes, like Byte and Integer, have public final fields (constants). These tell us properties of the number types themselves.
Type, size, min and max. This program is repetitive (sorry about that) but it serves its purpose. It displays the TYPE code, the SIZE and the min and max values.
TYPE:
This returns a class reference. This matches the shortened type, like int for Integer.
SIZE:
This returns the numbers of bits in the type. There are 8 bits in a byte.
MIN_VALUE:
This is the smallest value the numeric class can represent. All the types except Char have sign bits.
MAX_VALUE:
This is the highest value possible in a type. For Double and Long, these are huge.
Sign bits. All the types above (except char) have a sign bit. This is different from other languages—in C# for example a byte is unsigned, and an sbyte is signed.
Char:
This type is equivalent in both Java and C#. It is equivalent to a short with no sign bit (an unsigned short or ushort).
Character
Loop boundaries. MAX_VALUE and MIN are helpful in loops. Sometimes you may want a high number—the maximum constant is convenient.
Byte. The byte uses 8 bits of storage. In Java the byte is a signed number, so it can be negative or positive. We can cast larger values to bytes, but they will overflow.
Short. This is a two-byte integral type. It has a sign bit, so it supports negative and positive numbers. We use short to save memory, and to improve compatibility with existing software.
Long. This is an 8-byte integral number type, twice the size of an int. This program creates a long from a value that cannot be stored in an int—it is too large.
Float. This is a floating-point, 4-byte number. A float is like a double but only has 4 bytes (a double has twice as many bytes).
With this type, we can store numbers with a decimal place. A float can be cast to a double without any special syntax. But we must be careful when converting from a double to a float.
Max, min values. Floats can store a wide range of values. But with floats we also find a "normal values" concept. A normal value is within a "balanced range" of values.
Double. A double is twice the size of a float. It is 8 bytes (which is equal to 64 bits). Doubles are used to store floating point values.
In Java, we use the Double class to access static methods and constants on a double. We can find useful constants like BYTES but also methods like isNaN to test for special double values.
Watch video 3. Java Data Types Introduction. online without registration, duration hours minute second in high quality. This video was added by user DASARI TUTS 26 August 2017, don't forget to share it with your friends and acquaintances, it has been viewed on our site 27 once and liked it people.