Java Tutorials - Herong's Tutorial Notes
Dr. Herong Yang, Version 6.00

Java Tutorials - Herong's Tutorial Notes

http://www.herongyang.com/java

Copyright © 2008 by Dr. Herong Yang. All rights reserved.

HerongYang.com This Java book is a collection of notes and sample codes written by the author while he was learning Java himself. It covers topics related Java language core features and classes provided in the java.lang.* package: array, bit, byte, deadlock, expression, main method, synchronization, string, thread.

Table of Contents

About This Book

Installing JDK 1.4 on Windows 2000

Downling and Installing JDK 1.4

Writing My First Java Program

Installing JDK 1.5 on Windows XP

Downling and Installing JDK 1.5

Writing My First Java Program

Installing JDK 1.6 on Windows XP

Downling and Installing JDK 1.6

Writing My First Java Program

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

Bits, Bytes, Bitwise and Shift Operations

What Are Bits and Bytes

"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 Shift

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

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

JVM and OS System Properties

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

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

JDK 1.3 Bug - Memory Leak With Unstarted Threads

Synchronization Technique and Synchronized Code Blocks

Why Synchronization Is Needed in Multi-Threading Applications?

Synchronization Technique - Lock and Synchronized Code

"synchronized" - How Java Supports Synchronization

BankingThread.java - Synchronization Sample Program

BankingThread.java - Synchronization Sample Program Output

Deadlock Condition Example Programs

What Is Deadlock?

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

References

PDF Printing Version

Keywords: Java, Tutorial, Example, Sample, Book, JDK, JVM

Dr. Herong Yang, updated in 2008
Table of Contents