Book description
Beginning Java 8 Language Features covers essential and advanced features of the Java programming language such as the new lambda expressions (closures), inner classes, threads, I/O, Collections, garbage collection, streams, and more. Author Kishori Sharan provides over 60 diagrams and 290 complete programs to help you visualize and better understand the topics covered in this book.
The book starts with a series of chapters on the essential language features provided by Java, including annotations, inner classes, reflection, and generics. These topics are then complemented by details of how to use lambda expressions, allowing you to build powerful and efficient Java programs. The chapter on threads follows this up and discusses everything from the very basic concepts of a thread to the most advanced topics such as synchronizers, the fork/join framework, and atomic variables.
This book contains unmatched coverage of Java I/O, including NIO 2.0, the Path API, the FileVisitor API, the watch service and asynchronous file I/O. With this in-depth knowledge, your data- and file-management programs will be able to take advantage of every feature of Java's powerful I/O framework.
Finally, you'll learn how to use the Stream API, a new, exciting addition to Java 8, to perform aggregate operations on collections of data elements using functional-style programming. You'll examine the details of stream processing such as creating streams from different data sources, learning the difference between sequential and parallel streams, applying the filter-map-reduce pattern, and dealing with optional values.
Table of contents
- Cover
- Title
- Copyright
- Dedication
- Contents at a Glance
- Contents
- About the Author
- About the Technical Reviewer
- Acknowledgments
- Foreword
- Introduction
-
Chapter 1: Annotations
- What Are Annotations?
- Declaring an Annotation Type
- Restrictions on Annotation Types
- Default Value of an Annotation Element
- Annotation Type and Its Instances
- Using Annotations
- No Null Value in an Annotation
- Shorthand Annotation Syntax
- Marker Annotation Types
- Meta-Annotation Types
- Commonly Used Standard Annotations
- Annotating a Java Package
- Accessing Annotations at Runtime
- Evolving Annotation Types
- Annotation Processing at Source Code Level
- Summary
-
Chapter 2: Inner Classes
- What Is an Inner Class?
- Advantages of Using Inner Classes
- Types of Inner Classes
- A static Member Class Is Not an Inner Class
- Creating Objects of Inner Classes
- Accessing Enclosing Class Members
- Restrictions on Accessing Local Variables
- Inner Class and Inheritance
- No static Members in an Inner Class
- Generated Class Files for Inner Classes
- Inner Classes and the Compiler Magic
- Closures and Callbacks
- Defining Inner Classes in Static Contexts
- Summary
- Chapter 3: Reflection
-
Chapter 4: Generics
- What Are Generics?
- Supertype-Subtype Relationship
- Raw Type
- Unbounded Wildcards
- Upper-Bounded Wildcards
- Lower-Bounded Wildcards
- Generic Methods and Constructors
- Type Inference in Generic Object Creation
- No Generic Exception Classes
- No Generic Anonymous Classes
- Generics and Arrays
- Runtime Class Type of Generic Objects
- Heap Pollution
- Varargs Methods and Heap Pollution Warnings
- Summary
- Chapter 5: Lambda Expressions
-
Chapter 6: Threads
- What Is a Thread?
- Creating a Thread in Java
- Specifying Your Code for a Thread
- Using Multiple Threads in a Program
- Issues in Using Multiple Threads
- Java Memory Model (JMM)
- Object’s Monitor and Threads Synchronization
- The Producer/Consumer Synchronization Problem
- Which Thread Is Executing?
- Letting a Thread Sleep
- I will Join You in Heaven
- Be Considerate to Others and Yield
- Life Cycle of a Thread
- Priority of a Thread
- Is It a Demon or a Daemon?
- Am I Interrupted?
- Threads Work in a Group
- Volatile Variables
- Stopping, Suspending, and Resuming a Thread
- Handling an Uncaught Exception in a Thread
- New Thread Concurrency Packages
- Atomic Variables
- Explicit Locks
- Synchronizers
- The Executor Framework
- The Fork/Join Framework
- Thread-Local Variables
- Setting Stack Size of a Thread
- Summary
-
Chapter 7: Input/Output
- What Is Input/Output?
- Working with Files
- The Decorator Pattern
- Input/Output Streams
- Input Stream Meets the Decorator Pattern
- Output Stream Meets the Decorator Pattern
- Using Pipes
- Reading and Writing Primitive Data Types
- Object Serialization
- Serialization of transient Fields
- Advanced Object Serialization
- Readers and Writers
- Custom Input/Output Streams
- Random Access Files
- Copying the Contents of a File
- Standard Input/Output/Error Streams
- Console and Scanner Classes
- StringTokenizer and StreamTokenizer
- Summary
- Chapter 8: Working with Archive Files
- Chapter 9: New Input/Output
- Chapter 10: New Input/Output 2
-
Chapter 11: Garbage Collection
- What Is Garbage Collection?
- Memory Allocation in Java
- Garbage Collection in Java
- Invoking the Garbage Collector
- Object Finalization
- Finally or Finalize?
- Object Resurrection
- State of an Object
- Weak References
- Accessing and Clearing a Referent’s Reference
- Using the SoftReference Class
- Using the ReferenceQueue Class
- Using the WeakReference Class
- Using the PhantomReference Class
- Summary
-
Chapter 12: Collections
- What Is a Collection?
- Need for a Collection Framework
- Architecture of the Collection Framework
- The Collection Interface
- A Quick Example
- Traversing Collections
- Using Different Types of Collections
- Applying Algorithms to Collections
- Creating Different Views of a Collection
- Creating Empty Collections
- Creating Singleton Collections
- Understanding Hash-based Collections
- Summary
-
Chapter 13: Streams
- What Is a Stream?
- A Quick Example
- Creating Streams
- Representing an Optional Value
- Applying Operations on Streams
- Collecting Data Using Collectors
- Collecting Summary Statistics
- Collecting Data in Maps
- Joining Strings Using Collectors
- Grouping Data
- Partitioning Data
- Adapting the Collector Results
- Finding and Matching in Streams
- Parallel Streams
- Summary
- Index
Product information
- Title: Beginning Java 8 Language Features: Lambda Expressions, Inner Classes, Th reads, I/O, Collections,and Streams
- Author(s):
- Release date: August 2014
- Publisher(s): Apress
- ISBN: 9781430266594
You might also like
book
Java Language Features: With Modules, Streams, Threads, I/O, and Lambda Expressions
Work with essential and advanced features of the Java programming language such as Java modules development, …
video
Java 8 Lambdas and Streams
In this Java 8 Lambdas and Streams training course, expert author Madhusudhan Konda will teach you …
video
Java Lambdas and the Stream API: Bringing Functional Programming to Java
Come up to speed with Java functional programming and write effective Java code with less effort …
book
Java 8 Lambdas
If you’re a developer with core Java SE skills, this hands-on book takes you through the …