A Functional Approach to Java
This is the accompanying repository for the O'Reilly book A Functional Approach to Java.
How To Use
The code and files are split into three categories:
- JShell
- Java
- Other
The actual implementation of the examples might differ from their counterparts in the book to make them easier to use or runnable.
JShell
The examples from the book can mostly be run directly in JShell by either running jshell
and pasting the code into it or using a redirect, e.g., jshell < file.java
instead.
Some code, however, demonstrates invalid code, and either throws Exceptions or won't compile at all.
Even though most of the import
statements aren't required, they are still there to ensure everything works, regardless of your JShell configuration, or if you want to use the code in your favorite IDE.
Java
There are two types of examples in the folder java
.
Runnable examples often wrap multiple types into a singular class with a public static void main
method to run the actual code.
Other files are representations of certain designs and as such not runnable on their own.
Since Java 11, you don't need to compile the file beforehand, e.g., javac ExampleFile.java
and then java ExampleFile
.
Instead, java ExampleFile.java
compiles and runs it in a single step.
Other Files
The other
examples are mostly non-Java languages and partial Java code that's non-runnable or incomplete.
Chapter 14 is an exception, as it's a Gradle-project with dedicated tasks for each example.
See its README.md
for more info.
Buying the book
Besides using the O'Reilly Learning Platform, you can buy a paperback version of the book at your favorite store. Here are a few direct links to US stores:
ISBN-10: 1098109929
ISBN-13: 9781098109929