Java 8 Practical PDF

Source: Internet
Author: User
Tags error handling time zones stack trace

: Network Disk Download

Content Introduction· · · · · ·

This book provides a comprehensive overview of the new features of the milestone version of Java 8, including lambdas, streaming, and functional programming. With functional programming features, you can make your code more concise, and you can automate the use of multicore hardware. The book is divided into four parts: basic knowledge, functional data processing, high-efficiency Java 8 programming and beyond Java 8, clearly to the reader to show a modern Java picture of the Times.

Author profile ...

Author Profile:

Raoul-gabriel Urma

PhD in computer science, software engineer, lecturer, trainer, Cambridge Coding Academy co-founder and CEO, Cambridge University. He has worked with large companies such as Google, EBay, Oracle and Goldman Sachs, and has been involved in several entrepreneurial projects. He has authored over 10 peer-reviewed technical articles and delivered more than 40 presentations at international conferences.

Mario Fusco

Red Hat Senior Software engineer, responsible for the core development of JBoss Rule engine drools. With extensive experience in Java development, he has led the development of enterprise-level projects in various industries such as media companies and financial departments. Strong interest in functional programming and domain-specific languages, and the creation of open Source Library Lambdaj.

Alan Mycroft

Professor of Computer Laboratory computing at Cambridge University, researcher at Robinson College, University of Cambridge, co-founder of the European Association of Programming languages and systems, and co-founder and trustee of the Raspberry Pi Foundation. He has published about 100 research papers and directed over 20 doctoral theses. His research focuses on programming languages and their semantics, optimization, and implementation. He is closely connected with the industry, worked at the T lab and Intel during his academic leave, and founded the Codemist company, which designed the original arm C compiler norcroft.

Translator Profile:

Lu Minggang

Graduated from Sichuan University, currently a chief engineer at EMC China Excellence Research Group, has served as technical manager of Trend Micro China Software Development Center, has more than more than 10 years of practice and research experience in the field of information science and engineering, and has a number of Chinese and American patents. Focus on JVM performance tuning and big data and its practices, like digging into the inside of technology and being bored.

Lao

Master's degree from Shanghai Jiaotong University and now an advanced software support consultant at SAP USA. Hobby language, mathematics, design, in recent years translated and published the "Mystery of consultation", "Excellent programmer password" and other books.

Catalogue ... the first part of the basics
1th Chapter Why care about Java 8 2
1.1 How the Java is still changing 4
1.1.1 Location of Java in the programming language ecosystem 4
1.1.2 Stream Processing 6
1.1.3 using behavior parameterization to pass code to method 7
1.1.4 variable data for parallel and shared 7
1.1.5 Java needs to evolve 8
1.2 Functions in Java 8
1.2.1 Method and lambda as a class citizen 9
1.2.2 Pass Code: an example 11
1.2.3 from transfer method to lambda 12
1.3 Stream 13
1.4 Default Method 17
1.5来 other good ideas for self-functional programming 18
1.6 Summary 19
The 2nd chapter through the behavior of the parameterized pass code 20
2.1 Responding to changing needs 21
2.1.1 Preliminary sledgehammer: Screening Green Apple 21
2.1.2 again: Color as a parameter 21
2.1.3 Third attempt: Filter on every attribute you can think of 22
2.2 Behavior parameterization 23
2.3 Dealing with wordy 27
2.3.1 Anonymous Class 28
2.3.2 Fifth attempt: using anonymous class 28
2.3.3 Sixth attempt: using lambda expression 30
2.3.4 Seventh attempt: abstracting the list type 31
2.4 Real Examples 31
2.4.1 using comparator to sort 31
2.4.2 executing a code block with runnable 32
2.4.3 GUI Event Handling 32
2.5 Summary 33
3rd-Lambda Expression 34
3.1 Lambda Glimpse 35
3.2 Where and how to use lambda 37
3.2.1 Functional Interface 37
3.2.2 Function Descriptor 39
3.3 Put lambda into practice: Surround execution Mode 41
3.3.1 1th Step Remember behavior parameterization 41
3.3.2 Step 2nd: Using a functional interface to pass behavior 42
3.3.3 3rd Step: Perform a behavior 42
3.3.4 4th step: Pass Lambda 42
3.4 Using a functional interface 43
3.4.1 Predicate 44
3.4.2 Consumer 44
3.4.3 Function 45
3.5 type checking, type inference, and throttling 49
3.5.1 Type checking 49
3.5.2 the same lambda, different functional interface 50
3.5.3 Type Inference 51
3.5.4 using local Variables 52
3.6 Method Reference 53
3.6.1 Glimpse 53
3.6.2 Constructor Reference 55
3.7 Lambda and method reference combat 57
3.7.1 1th Step: Pass Code 58
3.7.2 2nd step: Using anonymous Class 58
3.7.3 3rd step: Using lambda expression 58
3.7.4 4th Step: Use method Reference 59
3.8 Useful methods for composite lambda expressions 59
3.8.1 Comparator Composite 60
3.8.2 predicate compound 60
3.8.3 function Composite 61
3.9 Similar ideas in mathematics 62
3.9.1 Points 62
3.9.2 associated with the lambda of Java 8 63
3.10 Summary 64
The second part of function-type data processing
The 4th chapter introduces stream 68
What is 4.1 stream 68
4.2 Stream Introduction 72
4.3 Streams and sets 74
4.3.1 can only traverse once 75
4.3.2 External iterations and internal iterations 76
4.4 Stream Operation 78
4.4.1 Intermediate Operation 78
4.4.2 Terminal Operation 79
4.4.3 using Stream 80
4.5 Summary 81
Chapter 5th using Flow 82
5.1 Filtering and slicing 83
5.1.1 Filtering with predicates 83
5.1.2 filtering elements in different 83
5.1.3 Truncated stream 84
5.1.4 Skip Element 85
5.2 Mapping 86
5.2.1 each element of the convection application function 86
Flattening of the 5.2.2 Stream 87
5.3 Finding and matching 90
5.3.1 checks if a predicate matches at least one element 90
5.3.2 checks if the predicate matches all elements 90
5.3.3 finding elements 91
5.3.4 finding the first element 92
5.4 Return about 92
5.4.1 Element Summation 93
5.4.2 Maximum and minimum value 94
5.5 Put into practice 97
5.5.1 field: Traders and trading 98
5.5.2 Solution 99
5.6 Value Stream 101
5.6.1 primitive type of Flow 101
5.6.2 Value Range 102
5.6.3 Numerical Flow application: Hook number 103
5.7 Build Stream 105
5.7.1 creating a stream by value 106
5.7.2 creating a stream from an array 106
5.7.3 generating streams from files 106
5.7.4 generated stream by function: Create Infinite stream 107
5.8 Summary 110
The 6th chapter collects data by stream 111
6.1 Collector Introduction 112
6.1.1 Collector for advanced attribution approx. 112
6.1.2 Pre-defined collector 113
6.2 Attribution and Rollup 114
6.2.1 Finding the maximum and minimum values in a stream 114
6.2.2 Summary 115
6.2.3 Connection String 116
6.2.4 Generalized Normalization Rollup 117
6.3 Grouping 120
6.3.1 Multilevel Grouping 121
6.3.2 collecting data by sub-group 122
6.4 Partition 126
Advantages of 6.4.1 Partitioning 126
6.4.2 numbers by prime and non-prime number partitioning 128
6.5 Collector Interface 129
6.5.1 Understanding method of collector Interface declaration 130
6.5.2 all fused together 134
6.6 Develop your own collectors for better performance 135
6.6.1 divide only by prime number 136
6.6.2 Comparison of collector performance 139
6.7 Summary 140
The 7th chapter Parallel Data processing and performance 141
7.1 Parallel Stream 141
7.1.1 converting a sequential stream to a parallel stream 142
7.1.2 Measuring Flow Performance 144
7.1.3 using parallel streams correctly 147
7.1.4 Efficient use of parallel streams 148
7.2 Branch/Merge frame 149
7.2.1 using Recursivetask 149
7.2.2 Best Practices for using branch/merge Frameworks 153
7.2.3 Job Theft 154
7.3 Spliterator 155
7.3.1 Splitting process 155
7.3.2 realize your own Spliterator 157
7.4 Summary 162
Part III High-efficiency Java 8 programming
8th. Refactoring, testing and commissioning 164
8.1 Refactoring code for improved readability and flexibility 164
8.1.1 improving the readability of code 165
8.1.2 conversion from an anonymous class to a lambda expression 165
8.1.3 conversion from a lambda expression to a method reference 166
8.1.4 switching from imperative data processing to stream 167
8.1.5 adding flexibility to your code 168
8.2 Using lambda to refactor object-oriented design Patterns 170
8.2.1 Policy Mode 171
8.2.2 Template Method 172
8.2.3 Observer Mode 173
8.2.4 Responsibility Chain Mode 175
8.2.5 Factory Mode 177
8.3 Testing a lambda expression 178
8.3.1 testing the behavior of a visible lambda function 179
8.3.2 testing the behavior of a method using lambda 179
8.3.3 to separate complex lambda expressions into different methods 180
8.3.4 High-order function test 180
8.4 Commissioning 181
8.4.1 View Stack Trace 181
8.4.2 Using log Debugging 183
8.5 Summary 184
9th. Default Method 185
9.1 Evolving API 187
9.1.1 Initial version of API 188
9.1.2 Second Edition API 188
9.2 Overview Default Method 190
9.3 Usage Mode for default methods 192
9.3.1 Optional Method 192
Multiple inheritance of 9.3.2 behavior 192
9.4 Rules for conflict resolution 196
9.4.1 three rules to solve the problem 196
9.4.2 Select the interface that provides the most specific implementation of the default method 197
9.4.3 conflict and how to explicitly eliminate ambiguity 198
9.4.4 Diamond Inheritance Problem 200
9.5 Summary 201
The 10th chapter replaces null 202 with optional
10.1 How to model missing values 203
10.1.1 use defensive check to reduce null-pointerexception 203
10.1.2 Null brings about a variety of problems 204
10.1.3 alternatives to NULL in other languages 205
10.2 Introduction to Optional class 206
10.3 Several modes of applying optional 207
10.3.1 Creating a optional object 208
10.3.2 extracting and converting values from a optional object using map 208
10.3.3 using Flatmap link Optional Object 209
10.3.4 default behavior and dereference optional object 213
10.3. Combination of 52 optional objects 213
10.3.6 using filter to reject a specific value 214
10.4 Practical examples of using optional 216
10.4.1 using optional to encapsulate a possible null value of 216
Comparison of 10.4.2 anomalies with optional 217
10.4.3 all the content together 218
10.5 Summary 219
11th Chapter Completablefuture: Combined asynchronous Programming 220
11.1 Future Interface 222
11.1.1 limitations of the future interface 223
11.1.2 using Completablefuture to build asynchronous applications 223
11.2 Implementing the Asynchronous API 224
11.2.1 converting a synchronous method to Async method 225
11.2.2 Error Handling 227
11.3 Keep your code from being blocked 228
11.3.1 using parallel streams to perform parallel operations on requests 229
11.3.2 initiating an asynchronous request using Completablefuture 230
11.3.3 looking for a better solution 232
11.3.4 using a custom actuator 233
11.4 pipelined Operations on multiple asynchronous tasks 234
11.4.1 to achieve discounted service 235
11.4.2 Using Discount Service 236
11.4.3 constructing synchronous and asynchronous operations 237
11.4.4 integrates two Completable-future objects, regardless of whether they have a dependency of 239
11.4.5 review of the future and the Completable-future 241
11.5 Response to Completablefuture completion event 242
11.5.1 optimization of the best price Finder application 243
11.5.2 put into practice 244
11.6 Summary 245
12th Chapter new Date and Time API 246
12.1 localdate, LocalTime, Instant, duration and period 247
12.1.1 using Localdate and LocalTime 247
12.1.2 Merge Date and time 248
12.1.3 date and time format of the machine 249
12.1.4 defining duration or period 249
12.2 Manipulating, parsing, and formatting date 251
12.2.1 using Temporaladjuster 253
12.2.2 print output and parse date-time object 255
12.3 Processing of different time zones and calendars 256
12.3.1 Calculating time zones using fixed deviations from and utc/GMT 257
12.3.2 using another calendar system 258
12.4 Summary 259
Part IV beyond Java 8
The 13th chapter of functional Thinking 262
13.1 Implementing and maintaining the system 262
13.1.1 Shared variable Data 263
13.1.2 Declarative Programming 264
13.1.3 Why to use functional programming 265
13.2 What is functional programming 265
13.2.1 Functional Java Programming 266
13.2.2 Citation Transparency 268
13.2.3 Object-oriented programming vs. Functional programming 268
13.2.4 Functional Programming Combat 269
13.3 Recursion and Iteration 271
13.4 Summary 274
The 14th chapter of functional Programming skills 275
14.1 Ubiquitous Functions 275
14.1.1 Higher order function 275
14.1.2 277
14.2 Persisting data Structures 278
14.2.1 comparison of broken and functional updates 279
14.2.2 Another example of using tree 281
14.2.3 using a functional approach 282
14.3 Stream's delay calculation 283
14.3.1 a custom stream 283
14.3.2 Create your own list of delays 286
14.4 Pattern Matching 290
14.4.1 Visitor Design Mode 291
14.4.2 using pattern matching to tide 292
14.5 Miscellaneous 295
14.5.1 Cache or Memory table 295
14.5.2 what does "return the same object" mean 296
14.5.3 Connector 296
14.6 Summary 297
15th hybrid of object-oriented and functional programming: Comparison of Java 8 and Scala 299
15.1 Scala Introduction 300
15.1.1 Hello, beer 300
15.1.2 BASIC Data structures: List, Set, Map, Tuple, stream, and option 302
15.2 Functions 306
15.2.1 A-class function in Scala 307
15.2.2 anonymous functions and closures 307
15.2.3 309
Class 15.3 and Trait 310
15.3.1 more concise Scala class 310
15.3.2 Scala's Trait vs. Java 8 interface 311
15.4 Summary 312
16th Chapter conclusion and the future of Java 313
16.1 Review the language features of Java 8 313
16.1.1 behavior parameterization (Lambda and method Reference) 314
16.1.2 Stream 314
16.1.3 completablefuture 315
16.1.4 Optional 315
16.1.5 default method 316
16.2 The future of Java 316
16.2.1 set of 316
Improvement of 16.2.2 type System 317
16.2.3 Pattern Matching 318
16.2.4 Richer Generic form 319
16.2.5 deeper support for immutability 321
16.2.6 Value Type 322
16.3 written in the last words 325
Appendix A update for other language features 326
Appendix B-Class Library update 330
Appendix C How to perform multiple operations on the same stream in a concurrent manner 338
Appendix D lambda Expressions and JVM byte-codes 346

: Network Disk Download

Java 8 Practical PDF

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.