Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1

© Wallace Jackson 2017 87
W. Jackson, Pro Java 9 Games Development, https://doi.org/10.1007/978-1-4842-0973-8_5


CHAPTER 5


A Java Primer: Introduction to


Java Concepts and Principles


Let’s make sure that all of our readers are on the same page here in Chapter 5 by reviewing the core
programming language concepts and principles behind the Java programming language. It is important
that we take this chapter to give our readers a Java “primer,” or comprehensive overview, and concisely
review the programming language in a single chapter. The Java 9 JDK (and JRE) that you installed in the
first chapter of this book will be the foundation for your Pro Java Games and IoT applications, as well as for
the NetBeans 9 IDE. (We’ll cover NetBeans in the next chapter so you can see how the IDE that you will be
using to code Java 9 games or IoT applications functions as a code editor and application testing tool.)
Most of the core Java constructs and principles that we will be covering during this chapter go back fairly
far in the Java programming language, most as far back as Java 5 (known as 1.5) or Java 6 (1.6). We will also be
covering the features added in Java 7 (1.7) and Java 8 (1.8), which is the most recent release, as well as the new
features planned for Java 9 (1.9), which will be released in the third quarter of 2017. These versions of Java are
used on billions of devices. Java 6 is used in the 32-bit Android 2.x, 3.x, and 4.x OS and applications; Java 7 is
used in the 64-bit Android 5.x and 6 OS and applications; Java 8 is used in Android 7 through 8, and in popular
operating systems (including Microsoft Windows, Apple Macintosh, Open Solaris, and a plethora of popular Linux
distributions such as SUSE, Ubuntu, Mint, Fedora, and Debian); and Java 9 is now released to the general public.
You will of course learn about new advanced concepts of Java 8 such as Lambda Expressions and about
Java 8 and Java 9 components, such as the JavaFX multimedia engine, as we progress through the book. This
chapter will cover the most foundational Java programming language concepts, techniques, and principles
that span the five major versions of Java that are currently in widespread use today, on computers, iTV sets,
and handheld devices.
We will start out with the easiest concepts and progress to the more difficult ones, so we will be starting
at the highest level of Java, which is the API and its modules, and then progress down to those “hands-on”
parts of the Java programming constructs inside of those modules, including packages, classes, interfaces,
methods, constants, and variables.
Before you get into the structural part of Java, such as packages, classes, and methods, you will take a
look at Java syntax, including what Java keywords are, how to delimit Java programming structures, and
how to add function comments into your Java code. Then we’ll cover top-level concepts of application
programming interfaces (APIs), what a package is, and how you can import and use existing code
provided by Java packages that are part of this API, as well as how to create custom Java packages of your
own that contain your own games and IoT application code.
You will take a look at the constructs that are held inside of the Java packages, which are called Java
classes. You will learn about the methods, variables, and constants that classes contain; about what
superclasses and subclasses are; and about what nested classes and inner classes are and how to use them.
Finally, you’ll learn about Java objects and how they form the foundation of Object-Oriented Programming
(OOP). You will learn what a constructor method is and how it creates a Java object using a special kind of
method that has the same name as a class in which it is contained.

Free download pdf