Book 5
Programming Techniques
Contents at a Glance
Chapter 1: Programming Threads
Understanding Threads
Creating a Thread
Implementing the Runnable Interface
Creating Threads That Work Together
Using an Executor
Synchronizing Methods
Creating a Lock
Coping with Threadus Interruptus
Chapter 2: Using Regular Expressions
Creating a Program for Experimenting with Regular Expressions
Performing Basic Character Matching
Using Regular Expressions in Java Programs
Chapter 3: Using Recursion
Calculating the Classic Factorial Example
Displaying Directories
Writing Your Own Sorting Routine
Chapter 4: Working with Dates and Times
Pondering How Time is Represented
Picking the Right Date and Time Class for Your Application
Using the now Method to Create a Date-Time Object
Using the parse Method to Create a Date-Time Object
Using the of Method to Create a Date-Time Object
Looking Closer at the LocalDate Class
Extracting Information About a Date
Comparing Dates
Calculating with Dates
Formatting Dates
Looking at a Fun Birthday Calculator
Chapter 5: IoT Programming with Raspberry Pi
Introducing the Raspberry Pi
Setting Up a Raspberry Pi
Installing Java on a Raspberry Pi
Installing the Pi4J Library
Configuring the Geany Integrated Development Environment for Java Development
Examining GPIO Ports
Connecting an LED to a GPIO Port
Building a Raspberry Pi LED Circuit
Examining the Pi4J Library
Importing GPIO Types
Instantiating a GpioController
Provisioning GPIO Pins
Controlling the Pin State
The Morse Code Program
The Cylon Eyes Program
Working with Input Pins
Running the Button Switcher Program
Finding a Better Way to Handle Input Events