Beginning Java 8 Language Features [electronic resource] : Lambda Expressions, Inner Classes, Threads, I/O, Collections, and Streams /
Sharan, Kishori.author.
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.
Contents at a Glance; Introduction; Chapter 1: Annotations; What Are Annotations?; Declaring an Annotation Type; Restrictions on Annotation Types; Restriction #1; Restriction #2; Restriction #3; Restriction #4; Restriction #5; Restriction #6; Default Value of an Annotation Element; Annotation Type and Its Instances; Using Annotations; Primitive Types; String Types; Class Types; Enum Type; Annotation Type; Array Type Annotation Element; No Null Value in an Annotation; Shorthand Annotation Syntax; Marker Annotation Types; Meta-Annotation Types; The Target Annotation Type
The Retention AnnotationThe Inherited Annotation Type; The Documented Annotation; The Repeatable Annotation; The Native Annotation; Commonly Used Standard Annotations; The Deprecated Annotation Type; The Override Annotation Type; The SuppressWarnings Annotation Type; The FunctionalInterface Annotation Type; 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; Member Inner Class; Local Inner Class
Anonymous Inner ClassA 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; What Is Reflection?; Reflection in Java; The java.lang.Class Class; Reflecting on a Class; Reflecting on Fields; Reflecting on an Executable; Reflecting on Methods
Reflecting on ConstructorsCreating Objects; Invoking Methods; Accessing Fields; Bypassing Accessibility Check; Reflecting on Arrays; Expanding an Array; Who Should Use Reflection?; Summary; 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 WarningsSummary; Chapter 5: Lambda Expressions; What Is a Lambda Expression?; Why Do We Need Lambda Expressions?; Syntax for Lambda Expressions; Omitting Parameter Types; Declaring a Single Parameter; Declaring No Parameters; Parameters with Modifiers; Declaring Body of Lambda Expressions; Target Typing; Functional Interfaces; Using the @FunctionalInterface Annotation; Generic Functional Interface; Intersection Type and Lambda Expressions; Commonly Used Functional Interfaces; Using the Function Interface; Using the Predicate Interface
Using Functional Interfaces
Includes index.
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.
Java (Computer program language).
Software engineering.
Java.
Software Engineering/Programming and Operating Systems.