Java Tutorials - Herong's Tutorial Examples
∟Primitive Data Types and Literals
∟Integer Data Types
This section describes value ranges and storage space sizes of integer data types: byte, short, int, long and char.
Java supports 5 integer data types: byte, short, int, long and char.
From the data value point of view, each integer data type can represent the following integer numbers:
- byte - Supports signed integer numbers in range from -128 to 127 inclusively.
- short - Supports signed integer numbers in range from -32768 to 32767 inclusively.
- int - Supports signed integer numbers in range from -2147483648 to 2147483647 inclusively.
- long - Supports signed integer numbers in range from -9223372036854775808 to 9223372036854775807 inclusively.
- char - Supports unsigned integer numbers in range from 0 to 65535 inclusively.
From the data storage point of view, each integer data type is stored its values differently:
- byte - Stores its value in a 8-bit (1-byte) space with the 1st bit representing the sign
and the remaining 7 bits representing the integer value in a binary format.
- short - Stores its value in a 16-bit (2-byte) space with the 1st bit representing the sign
and the remaining 15 bits representing the integer value in a binary format.
- int - Stores its value in a 32-bit (4-byte) space with the 1st bit representing the sign
and the remaining 31 bits representing the integer value in a binary format.
- long - Stores its value in a 64-bit (8-byte) space with the 1st bit representing the sign
and the remaining 63 bits representing the integer value in a binary format.
- char - Stores its value in a 16-bit (2-byte) space with all 16 bits representing the integer value in a binary format.
Table of Contents
About This Book
JDK - Java Development Kit
Execution Process, Entry Point, Input and Output
►Primitive Data Types and Literals
Data Types Supported in Java
►Integer Data Types
Floating-Point Data Types
Logical (Boolean) Data Type
Literals of Primitive Types
Literal Formats for Integers
Literal Formats for Integers - Example
Literal Formats for Floating-Point
Literal Formats for Floating-Point - Example
Literal Formats for Characters
Literal Formats for Character - Example
Control Flow Statements
Bits, Bytes, Bitwise and Shift Operations
Managing Bit Strings in Byte Arrays
Reference Data Types and Variables
Enum Types and Enum Constants
StringBuffer - The String Buffer Class
System Properties and Runtime Object Methods
Generic Classes and Parameterized Types
Generic Methods and Type Inference
Lambda Expressions and Method References
Java Modules - Java Package Aggregation
Execution Threads and Multi-Threading Java Programs
ThreadGroup Class and "system" ThreadGroup Tree
Synchronization Technique and Synchronized Code Blocks
Deadlock Condition Example Programs
Garbage Collection and the gc() Method
Assert Statements and -ea" Option
Annotation Statements and Declarations
Java Related Terminologies
Archived Tutorials
References
Full Version in PDF/EPUB