Java Tutorials - Herong's Tutorial Examples - v8.22, by Herong Yang
Java Tutorials - Herong's Tutorial Examples
https://www.herongyang.com/Java
Copyright © 1997-2024 Herong Yang. All rights reserved.
This tutorial book is a collection of notes and sample codes written by the author while he was learning Java himself. Topics covered in the book include: Java language basics; execution environment; generic classes and parameterized type; generic methods and type argument inferences; enum types and constants; lambda expressions; annotation types and invocations; Java modules; execution threads and synchronization; memory management and garbage collection. Updated in 2024 (Version v8.22) with JDK 20.
Table of Contents
Downloading and Installing JDK on Mac
Downloading and Installing JDK on Windows
Adding JDK "bin" Directory to Path Setting
Downloading and Installing JDK on Linux
JDK Documentation Installation
Execution Process, Entry Point, Input and Output
Creating, Compiling and Executing Java Programs
main() Method - Java Execution Entry Point
Java Execution Console - "in", "out" and "err" Data Streams
Primitive Data Types and Literals
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
What Is Control Flow Statement
Nested "if-then-else" Statements
Fall-Through Behavior of "switch" Statements
Bits, Bytes, Bitwise and Shift Operations
"byte" Data Type and Implicit Casting
Operations on "byte" Data Type Values
Bitwise Operations on "byte" Values
Bitwise Operations on "byte" Values - Example Program
Shift Operations - Left, Right or Unsigned Right
Managing Bit Strings in Byte Arrays
setBit() - Storing a Bit into a Byte Array
getBit() - Retrieving a Bit from a Byte Array
rotateLeft() - Left Rotating All Bits in a Byte Array
bitStringTest.java - Testing Program
Reference Data Types and Variables
Reference Types Supported in Java
Class Type Variables Storing References
Explicit and Implicit Type Casting
Type Casting Compile and Runtime Error
Use 'class' to Define Enumeration
Instance Variables for Enum Constants
Enum Constant Inherited Methods
Enum Constant Implicit Methods
StringBuffer - The String Buffer Class
StringBuffer Class Properties and Methods
SimpleStringBuffer - My Implementation of String Buffer
Performance Comparison of String and StringBuffer
System Properties and Runtime Object Methods
System.setProperty() - Setting Your Own Properties
Runtime.getRuntime() - Getting the Runtime Object
freeMemory() - Getting JVM Free Memory Information
Calculating Memory Usage of an Array
exec() - Executing Operating System Commands
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
What Are Processes and Threads
The "Thread" Class - Creating Thread Objects With Thread Sub Classes
The "Runnable" Interface - Creating Thread Objects with Runnable Objects
CPU Execution Time Shared by Multiple Threads
CPU Execution Time Shared by Multiple Threads - Test Output
Application Data Shared by Multiple Threads
Application Data Shared by Multiple Threads - Test Results
interrupt() - Method to Terminate Thread
ThreadGroup Class and "system" ThreadGroup Tree
"ThreadGroup" Class - Container of Threads and Thread Groups
Displaying the "system" ThreadGroup Tree
Adding Threads and Thread Groups
Synchronization Technique and Synchronized Code Blocks
Deadlock Condition Example Programs
Deadlock Example - 5 Dining Philosophers
Deadlock Example - Transferring Funds
Garbage Collection and the gc() Method
Garbage Collection and Unused Objects
The Automated Garbage Collection Process
gc() - The Garbage Collection Method
Example Program of Using the gc() Method
Assert Statements and -ea" Option
Annotation Statements and Declarations
Default Values for Annotation Elements
Single-Element Annotation Invocation
No-Element (Marker) Annotation Invocation
getAnnotations() Method - Annotation APIs
Archived: Downloading and Installing JDK 13 on Mac
Archived: Downloading and Installing JDK 10
Archived: JDK 10 Documentation Installation
Archived: Downloading and Installing JDK 8
Archived: Downloading and Installing JDK 1.7
Archived: Downloading and Installing JDK 1.6
Archived: Downloading and Installing JDK 1.5
Keywords: Java, Language, Tutorial