Skip to main content
main-content
Top

About this book

Pro Java 8 Programming covers the core Java development kit. It takes advantage of the finer points of the core standard edition (SE) and development kit version 8. You'll discover the particulars of working with the Java language and APIs to develop applications in many different contexts. You will also delve into more advanced topics like lambda expressions, closures, new i/o (NIO.2), enums, generics, XML, metadata and the Swing APIs for GUI design and development. By the end of the book, you’ll be fully prepared to take advantage of Java's ease of development, and able to create powerful, sophisticated Java applications.

Table of Contents

Chapter 1. Going Inside Java

Abstract
Java has been described as “a simple, robust, object-oriented, platform-independent, multithreaded, dynamic, general-purpose programming environment.” Living up to this definition allowed Java to grow and expand into so many niches that it’s almost unrecognizable from its earliest days. Today you can find Java just about anywhere you can find a microprocessor. It’s used in the largest of enterprises to the smallest of devices, and it’s used in devices from cell phones to supercooled mainframes. For Java to support such a wide range of environments, an almost bewildering array of application programming interfaces (APIs) and versions have been developed, though they’re built around a common set of core classes.
Brett Spell

Chapter 2. Designing Libraries, Classes, and Methods

Abstract
Understanding the mechanics of creating Java code is relatively easy, but creating a good object-oriented design is much more complex. In this context, good means that the code works correctly and is reasonably easy to understand, maintain, extend, and reuse. This chapter describes some guidelines that can help you create code with those characteristics.
Brett Spell

Chapter 3. Lambdas and Other Java 8 Features

Abstract
Rarely, if ever, has there been a new release of Java that created as much interest as Java 8, which was officially released in early 2014. By far the most talked-about change was the introduction of lambda expressions, although the new release also included a number of other changes, such as the following:
Brett Spell

Chapter 4. Using Threads in Your Applications

Abstract
If you’re like most users, you probably have more than one application running on your computer most of the time. In addition, you probably sometimes initiate a long-running task in one application and switch to another application while waiting for that task to complete. For example, you might start downloading a file from the Internet, or begin a search that scans your disk drive for files matching a particular pattern, and then read your e-mail while the download or search is in progress. Running multiple applications simultaneously (or at least appearing to do so) is called multitasking, and each application is usually referred to as a process.
Brett Spell

Chapter 5. Using Stream APIs and Collections

Abstract
By definition, an object-oriented application is one that creates and uses objects, and most useful applications create and manage groups of objects. In fact, maintaining a group, or collection, of objects is done so often that Java’s core library has always included classes designed specifically for that purpose.
Brett Spell

Chapter 6. Using Layout Managers

Abstract
In Java, you can use the java.awt.Container class and its subclasses to display groups of Swing components. For example, you might use a JPanel to display a related set of buttons or add components to a JFrame. Layout managers are classes that control the size and location of each component that’s added to a container, and in most cases a layout manager is also responsible for determining the sizes returned from the container’s getMinimumSize(), getPreferredSize(), and getMaximumSize() methods. Layout managers are important because they simplify the task of positioning and sizing components and because they allow you to create flexible user interfaces.
Brett Spell

Chapter 7. Using Swing’s JTable

Abstract
Many applications need to display data in a tabular form, and Swing provides a table component (also sometimes called a grid) that allows you to do so. The JTable class, defined in the javax.swing package, provides a great deal of functionality that you can use to create a user interface for viewing and updating data. This chapter covers some of the functionality that’s commonly needed when using a table component and illustrates how to implement it using. In the process, you’ll learn a great deal about how JTable works, how to use its existing capabilities, and how to extend its capabilities.
Brett Spell

Chapter 8. Using Swing’s JTree

Abstract
The component defined in the javax.swing package is commonly used to display hierarchical data such as the contents of a file system.
Brett Spell

Chapter 9. Adding Cut-and-Paste Functionality

Abstract
Cut-and-paste functionality is extremely useful because it allows you to transfer data between user interface components and even between different applications. In general, cut-and-paste operations are performed on components that support the concept of a selection, and the operations are initiated by the keyboard and performed for the component that currently has the input focus.
Brett Spell

Chapter 10. Adding Drag-and-Drop Functionality

Abstract
In a drag-and-drop operation, data is moved (dragged) from one location and stored (dropped) in another. For example, most operating systems provide a utility similar to Windows Explorer, which allows you to perform drag-and-drop operations on a list of available files. Drag-and-drop functionality provides an intuitive visual representation of moving or copying data from one location to another and is an important part of most modern operating systems. Many applications use it in a variety of ways, so it’s helpful to be familiar with the functionality that’s available in Java.
Brett Spell

Chapter 11. Printing

Abstract
Java matured very quickly in most respects after it was first introduced, but for a long time printing was one of Java’s weakest points. In fact, Java 1.0 didn’t offer any support for printing at all. Java 1.1 included a class called PrintJob in the java.awt package, but the printing capabilities supported by that class were somewhat crude and unreliable. When Java 1.2 (or “Java 2”) was introduced, it included a completely separate mechanism (the Java 2D printing API) for printing designed around PrinterJob and other classes and interfaces defined in the new java.awt.print package. This rendered the PrintJob-based printing mechanism (also known as AWT printing) largely obsolete, although PrintJob has never been deprecated and is still technically a supported class.
Brett Spell

Chapter 12. Introducing JDBC

Abstract
When your application creates or uses large amounts of data, it’s usually necessary for that information to be stored in a database. Although there has been significant growth in the use of NoSQL databases in recent years, the most widely used type of database is still a relational database, and some examples of relational database products are Oracle, DB2, Sybase, MySQL, and Microsoft SQL Server. A relational database product is sometimes referred to as a relational database management system (RDBMS, or simply DBMS), while a database usually refers to a collection of data managed by a DBMS.
Brett Spell

Chapter 13. Internationalizing Your Applications

Abstract
Occasionally software applications are used by only a small number of people within a limited geographic area, but it has become increasingly common for an application to be used by many people in different parts of the world. In some cases, it’s possible to require all your application’s users to understand a single language and use the same symbols and formatting for items such as dates, times, and numeric values. However, most users prefer to work with the language and formatting conventions they’re most comfortable with, and by taking that into consideration when designing your application, you can accommodate their wishes.
Brett Spell

Chapter 14. Using XML

Abstract
Although the two aren’t inherently tied together, the eXtensible Markup Language (XML) and Java are often discussed in the same context. This chapter explains why that’s the case and provides an overview of XML, along with a description of some of the tools available and when and how to use them. You’ll look at the following:
Brett Spell

Chapter 15. Adding Annotations

Abstract
A very useful part of Java is its support for annotations, which are used to define what is sometimes referred to as metadata. To understand what benefits this feature provides, it’s helpful to first realize that the definition of metadata is “data about data.” In other words, metadata is information that describes other data. An example of where metadata has long been used in Java is the java.sql package that contains DatabaseMetaData, ResultSetMetaData, and the relatively new ParameterMetaData interfaces. As implied by the definition just mentioned and by their names, these classes encapsulate data that describes a database, a ResultSet, and parameter information, respectively. For example, ResultSetMetaData allows you to find out how many columns are represented within a ResultSet, the data types associated with those columns, and so on.
Brett Spell
Additional information