The introduction of functional programming concepts in Java SE 8 was a drastic change for this venerable object-oriented language. Lambda expressions, method references, and streams fundamentally changed the idioms of the language, and many developers have been trying to catch up ever since. This cookbook will help. With more than 70 detailed recipes, author Ken Kousen shows you how to use the newest features of Java to solve a wide range of problems.
For developers comfortable with previous Java versions, this guide covers nearly all of Java SE 8, and includes a chapter focused on changes coming in Java 9. Need to understand how functional idioms will change the way you write code? This cookbook—chock full of use cases—is for you.
Recipes cover:
The basics of lambda expressions and method references
Interfaces in the java.util.function package
Stream operations for transforming and filtering data
Comparators and Collectors for sorting and converting streaming data
Combining lambdas, method references, and streams
Creating instances and extract values from Java’s Optional type
New I/O capabilities that support functional streams
The Date-Time API that replaces the legacy Date and Calendar classes
Mechanisms for experimenting with concurrency and parallelism
About the Author
Ken Kousen is an independent consultant and trainer specializing in Spring, Hibernate, Groovy, and Grails. He holds numerous technical certifications, along with degrees in Mathematics, Mechanical and Aerospace Engineering, and Computer Science.
Java continues to grow and evolve, and this cookbook continues to evolve in tandem. With this guide, you’ll get up to speed right away with hundreds of hands-on recipes across a broad range of Java topics. You’ll learn useful techniques for everything from string handling and functional programming to network communication.
Each recipe includes self-contained code solutions that you can freely use, along with a discussion of how and why they work. If you’re familiar with Java basics, this cookbook will bolster your knowledge of the language and its many recent changes, including how to apply them in your day-to-day development. This updated edition covers changes through Java 12 and parts of 13 and 14.
Recipes include:
Methods for compiling, running, and debugging
Packaging Java classes and building applications
Manipulating, comparing, and rearranging text
Regular expressions for string and pattern matching
Handling numbers, dates, and times
Structuring data with collections, arrays, and other types
Object-oriented and functional programming techniques
Input/output, directory, and filesystem operations
A practical introduction to Java programming—fully revised for long-term support release Java SE 11
Thoroughly updated for Java Platform Standard Edition 11, this hands-on resource shows, step by step, how to get started programming in Java from the very first chapter. Written by Java guru Herbert Schildt, the book starts with the basics, such as how to create, compile, and run a Java program. From there, you will learn essential Java keywords, syntax, and commands.
Java: A Beginner’s Guide, Eighth Edition covers the basics and touches on advanced features, including multithreaded programming, generics, Lambda expressions, and Swing. Enumeration, modules, and interface methods are also clearly explained. This Oracle Press guide delivers the appropriate mix of theory and practical coding necessary to get you up and running developing Java applications in no time.
Clearly explains all of the new Java SE 11 features
Features self-tests, exercises, and downloadable code samples
Written by bestselling author and leading Java authority Herbert Schildt
About the Author:
Herbert Schildt is one of the world’s leading programming authors and has written extensively on Java, C, C++, and C#. His books have sold millions of copies worldwide. Herb’s acclaimed books include Java: The Complete Reference, Java: A Beginner’s Guide, C: The Complete Reference, C++: The Complete Reference and C#: The Complete Reference.
Previous version from 2012, New version available Summer 2021
About This Book:
Understanding Java from the JVM up gives you a solid foundation to grow your expertise and take on advanced techniques for performance, concurrency, containerization, and more.
In The Well-Grounded Java Developer, Second Edition you will learn:
The new Java module system and why you should use it
Bytecode for the JVM, including operations and classloading
Performance tuning the JVM
Working with Java’s built-in concurrency and expanded options
Programming in Kotlin and Clojure on the JVM
Maximizing the benefits from your build/CI tooling with Maven and Gradle
Running the JVM in containers
Planning for future JVM releases
The Well-Grounded Java Developer, Second Edition introduces both the modern innovations and timeless fundamentals you need to know to become a Java master. Authors Ben Evans, Martijn Verburg, and Jason Clark distil their decades of experience as Java Champions, veteran developers, and key contributors to the Java ecosystem into this clear and practical guide.
about the technology
Java’s history of innovation, its huge collection of libraries and frameworks, and the flexibility of the JVM have cemented its place as one of the world’s most popular programming languages. Although it’s easy to get started with Java, understanding how the language intersects with the JVM is the key to unlocking the power of this awesome language and its deep ecosystem of frameworks, tools, and alternative JVM-based languages.
about the book
The Well-Grounded Java Developer, Second Edition is a complete revision of the classic original with the latest innovations of the Java platform. It upgrades your existing Java skills with both JVM fundamentals like bytecode, and powerful new features such as modules and concurrency models.
You’ll broaden your understanding of what’s possible by exploring Kotlin and other JVM languages, and learn how functional programming can offer a powerful new perspective. Each concept is illustrated with hands-on examples, including a fully modularized application/library, build setups for Maven and Gradle, and creating your own multithreaded application.
about the reader
For intermediate Java developers. No experience with the latest Java version or JVM languages required.
About the Authors:
Martijn Verburg is the principal SWE group manager for the Java Engineering Group at Microsoft. He is the co-leader of the London Java User Group (LJC) where he co-founded AdoptOpenJDK, the world’s leading (non-Oracle) OpenJDK distribution. He has been made a Java Champion in recognition for his contribution to the Java ecosystem.
Jason Clark is a principal engineer and architect at New Relic, and was previously an architect at WebMD. A regular conference speaker, Jason contributes to the open-source project Shoes, aiming to make GUI programming easy and fun for beginners.
Quickly gain the insight necessary to address a multitude of Java coding challenges using this succinct reference guide. Short, focused code examples will help you master Java elements such as modules, boxing/unboxing and more.
You won’t find any technical jargon, bloated samples, drawn out history lessons or witty stories in this book. What you will find is a language reference that is concise, to the point and highly accessible. The book is packed with useful information and is a must-have for any Java programmer.
What You Will Learn
Code with Java modules
Box/unbox
Utilize exception handling
Who This Book Is For
Those with prior experience with Java who want a quick and handy reference.
About the Author:
Mikael Olsson is a professional web entrepreneur, programmer, and author. He works for an R&D company in Finland where he specializes in software development. In his spare time he writes books and creates websites that summarize various fields of interest. The books he writes are focused on teaching their subject in the most efficient way possible, by explaining only what is relevant and practical without any unnecessary repetition or theory. The portal to his online businesses and other websites is Siforia.com.
Learning a complex new language is no easy task especially when it s an object-oriented computer programming language like Java. You might think the problem is your brain. It seems to have a mind of its own, a mind that doesn’t always want to take in the dry, technical stuff you’re forced to study.
The fact is your brain craves novelty. It’s constantly searching, scanning, waiting for something unusual to happen. After all, that’s the way it was built to help you stay alive. It takes all the routine, ordinary, dull stuff and filters it to the background so it won’t interfere with your brain’s real work–recording things that matter. How does your brain know what matters? It’s like the creators of the Head First approach say, suppose you’re out for a hike and a tiger jumps in front of you, what happens in your brain? Neurons fire. Emotions crank up. Chemicals surge.
That’s how your brain knows.
And that’s how your brain will learn Java. Head First Java combines puzzles, strong visuals, mysteries, and soul-searching interviews with famous Java objects to engage you in many different ways. It’s fast, it’s fun, and it’s effective. And, despite its playful appearance, Head First Java is serious stuff: a complete introduction to object-oriented programming and Java. You’ll learn everything from the fundamentals to advanced topics, including threads, network sockets, and distributed programming with RMI. And the new. third edition focuses on Java 17, the latest version of the Java language and development platform.
What will you learn from this book?
Ready to learn Java? This book combines puzzles, strong visuals, mysteries, and soul-searching interviews with famous Java objects to engage you in many different ways. It’s fast, it’s fun, and it’s effective. And, despite its playful appearance, Head First Java is serious stuff: a complete introduction to object-oriented programming and Java. You’ll learn everything from the fundamentals to advanced topics.
The new third edition brings the book up to date for Java 8-17, including major recent updates to the Java language and development platform. Java has seen some deep, code-level changes and more modern approaches, requiring even more careful study and implementation. So learning the Head First way is more important than ever.
What’s so special about this book?
If you’ve read a Head First book, you know what to expect–a visually rich format designed for the way your brain works. If you haven’t, you’re in for a treat. With this book, you’ll learn Java through a multi-sensory experience that engages your mind, rather than a text-heavy approach that puts you to sleep.
About the Authors:
Kathy Sierra, SCJP, was a codeveloper of the SCJP SCEA exams. Along with her partner Bert Bates, Kathy Sierra created the award-winning Head First programming book series that has sold over 1 million copies, and includes the longest-running tech bestsellers of the past decade. Her background is in developing education games and software for the motion picture industry, and she also created the first interaction design courses for UCLA Entertainment Studies. For more than 15 years she’s been helping large companies, small start-ups, non-profits, and educators rethink their approach to user experience, and build sustainable, genuine loyalty.
Kathy has been interested in learning theory since her days as a game developer (Virgin, MGM, Amblin’). More recently, she’s been a master trainer for Sun Microsystems, teaching Sun’s Java instructors how to teach the latest technologies to customers, and a lead developer of several Sun certification exams. She’s also the original founder of the Software Development/Jolt Productivity Award-winning https://javaranch.com, the largest (and friendliest) all-volunteer Java community.
Bert Bates, SCJP, OCA, OCP, is a Sun Certified Programmer for Java and has been developing software for the last 20 years. He has participated in the development of the SCJP, SCEA, and SCWCD exams. Bert has been teaching software development, including Java programming, for many years. Bert Bates is a 20-year software developer, a Java instructor, and a co-developer of Sun’s EJB exam (Sun Certified Business Component Developer), the SCJP exam and the SCJD exam. Bert has also been teaching software development, including Java programming, for many years. His background features a long stint in artificial intelligence, with clients like the Weather Channel, A&E Network, Rockwell, and Timken.
Currently used at many colleges, universities, and high schools, this hands-on introduction to computer science is ideal for people with little or no programming experience. The goal of this concise book is not just to teach you Java, but to help you think like a computer scientist. You’ll learn how to program—a useful skill by itself—but you’ll also discover how to use programming as a means to an end.
Authors Allen Downey and Chris Mayfield start with the most basic concepts and gradually move into topics that are more complex, such as recursion and object-oriented programming. Each brief chapter covers the material for one week of a college course and includes exercises to help you practice what you’ve learned.
Learn one concept at a time: tackle complex topics in a series of small steps with examples
Understand how to formulate problems, think creatively about solutions, and write programs clearly and accurately
Determine which development techniques work best for you, and practice the important skill of debugging
Learn relationships among input and output, decisions and loops, classes and methods, strings and arrays
Work on exercises involving word games, graphics, puzzles, and playing cards
The updated second edition of Think Java also features new chapters on polymorphism and data processing, as well as content covering changes through Java 12.
About the Authors:
Allen B. Downey is a Professor of Computer Science at Olin College of Engineering. He has taught at Wellesley College, Colby College, and U.C. Berkeley. He has a Ph.D. in Computer Science from U.C. Berkeley, and Master’s and Bachelor’s degrees from MIT. Downey is the creator of the bestselling Think series for O’Reilly, including Think Python, Think Complexity, Think DSP, and Think Bayes.
Chris Mayfield is an Assistant Professor of Computer Science at James Madison University, with a research focus on CS education and professional development. He has a Ph.D. in Computer Science from Purdue University and Bachelor’s degrees in CS and German from the University of Utah. https://github.com/ChrisMayfield and https://w3.cs.jmu.edu/mayfiecs
Write your first code in Java using simple, step-by-step examples that model real-word objects and events, making learning easy. With this book you’ll be able to pick up the concepts without fuss. Java for Absolute Beginners teaches Java development in language anyone can understand, giving you the best possible start. You’ll see clear code descriptions and layout so that you can get your code running as soon as possible. After reading this book, you’ll come away with the basics to get started writing programs in Java.
Author Iuliana Cosmina focuses on practical knowledge and getting up to speed quickly—all the bits and pieces a novice needs to get started programming in Java. First, you’ll discover how Java is executed, what type of language it is, and what it is good for. With the theory out of the way, you’ll install Java, choose an editor such as IntelliJ IDEA, and write your first simple Java program. Along the way you’ll compile and execute this program so it can run on any platform that supports Java. As part of this tutorial you’ll see how to write high-quality code by following conventions and respecting well-known programming principles, making your projects more professional and efficient.
Finally, alongside the core features of Java, you’ll learn skills in some of the newest and most exciting features of the language: Generics, Lambda expressions, modular organization, local-variable type inference, and local variable syntax for Lambda expressions.
Java for Absolute Beginners gives you all you need to start your Java 9+ programming journey. No experience necessary.
What You’ll Learn
Use data types, operators, and the new stream API
Install and use a build tool such as Gradle
Build interactive Java applications with JavaFX
Exchange data using the new JSON APIs
Play with images using multi-resolution APIs
Use the publish-subscribe framework
Who This Book Is For
Those who are new to programming and who want to start with Java.
About the Author:
Iuliana Cosmina is currently a Software Engineer for NCR Edinburgh. She has been writing Java code since 2002 and contributed to various types of applications such as experimental search engines, ERPs, track and trace, and banking. During her career, she has been a teacher, a team leader, software architect, DevOps professional and software manager. She is a Spring-certified Professional, as defined by Pivotal, the makers of Spring Framework, Boot, and other tools, and considers Spring the best Java framework to work with. When she is not programming, she spends her time reading, blogging, learning to play piano, travelling, hiking or biking.
Write your first code in Java 17 using simple, step-by-step examples that model real-word objects and events, making learning easy. With Java 17 for Absolute Beginners you’ll be able to pick up the concepts without fuss. It teaches Java development in language anyone can understand, giving you the best possible start.
You’ll see clear code descriptions and layout so that you can get your code running as soon as possible. Author Iuliana Cosmina focuses on practical knowledge and getting you up to speed quickly—all the bits and pieces a novice needs to get started programming in Java.
First, you’ll discover what type of language Java is, what it is good for, and how it is executed. With the theory out of the way, you’ll install Java, choose an editor such as IntelliJ IDEA, and write your first simple Java program. Along the way you’ll compile and execute this program so it can run on any platform that supports Java. As part of this tutorial you’ll see how to write high-quality code by following conventions and respecting well-known programming principles, making your projects more professional and efficient.
Java 17 for Absolute Beginners gives you all you need to start your Java programming journey. No experience necessary. After reading this book, you’ll come away with the basics to get started writing programs in Java.\
See: Modern Java in Action – Lambdas, streams, functional and reactive programming, 2nd Edition, by Raoul-Gabriel Urma, Mario Fusco, Alan Mycroft, 2018, 1617293563 (ModJavAc)
Manning’s bestselling Java 8 book has been revised for Java 9 and 10! In Modern Java in Action, you’ll build on your existing Java language skills with the newest features and techniques.
about the technology
Modern applications take advantage of innovative designs, including microservices, reactive architectures, and streaming data. Modern Java features like lambdas, streams, and the long-awaited Java Module System make implementing these designs significantly easier. It’s time to upgrade your skills and meet these challenges head on!
about the book
Modern Java in Action connects new features of the Java language with their practical applications. Using crystal-clear examples and careful attention to detail, this book respects your time. It will help you expand your existing knowledge of core Java as you master modern additions like the Streams API and the Java Module System, explore new approaches to concurrency, and learn how functional concepts can help you write code that’s easier to read and maintain.
what’s inside
Thoroughly revised edition of Manning’s bestselling Java 8 in Action
New features in Java 8, Java 9, and beyond
Streaming data and reactive programming
The Java Module System
about the reader
Written for developers familiar with core Java features.
Reviews
“My Java code improved significantly after reading this book. I was able to take the clear examples and immediately put them intopractice.”–Holly Cummins, IBM
“A comprehensive and practical introduction to the modern features of the latest Java releases with excellent examples!”–Oleksandr Mandryk, EPAM Systems
“Hands-on Java 8 and 9, simply and elegantly explained.”–Deepak Bhaskaran, Salesforce
“A lot of great examples and use cases for streams, concurrency, andreactive programming.”–Rob Pacheco, Synopsys
About the Authors:
Raoul-Gabriel Urma is CEO and co-founder of Cambridge Spark, a leading learning community for data scientists and developers in UK. In addition, he is also Chairman and co-founder of Cambridge Coding Academy, a growing community of young coders and pre-university students. Raoul is author of the bestselling programming book “Java 8 in Action” which sold over 20,000 copies globally. Raoul completed a PhD in Computer Science at the University of Cambridge. In addition, he holds a MEng in Computer Science from Imperial College London and graduated with first class honours having won several prizes for technical innovation. Raoul has delivered over 100 technical talks at international conferences. He has worked for Google, eBay, Oracle, and Goldman Sachs. He is also a Fellow of the Royal Society of Arts.
Mario Fusco is a senior software engineer at Red Hat working on Drools, the JBoss rule engine. He created the open source library lambdaj, an internal Java DSL for manipulating collections in a functional way.
Alan Mycroft is Professor of Computer Science at the University of Cambridge, where he researches programming languages, their semantics, optimization and implementation. He is a co-founder and Trustee of the Raspberry Pi Foundation.
Copyright Brief Table of Contents Table of Contents Praise for the previous edition, Java 8 in Action, by Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft. Preface Acknowledgments About this book About the authors About the cover illustration Part 1. Fundamentals
Part 2. Functional-style data processing with streams
Chapter 4. Introducing streams Chapter 5. Working with streams Chapter 6. Collecting data with streams Chapter 7. Parallel data processing and performance
Part 3. Effective programming with streams and lambdas
Chapter 8. Collection API enhancements Chapter 9. Refactoring, testing, and debugging Chapter 10. Domain-specific languages using lambdas
Part 4. Everyday Java
Chapter 11. Using Optional as a better alternative to null Chapter 12. New Date and Time API Chapter 13. Default methods Chapter 14. The Java Module System
Part 6. Functional programming and future Java evolution
Chapter 18. Thinking functionally Chapter 19. Functional programming techniques Chapter 20. Blending OOP and FP: Comparing Java and Scala Chapter 21. Conclusions and where next for Java
Appendix A. Miscellaneous language updates Appendix B. Miscellaneous library updates Appendix C. Performing multiple operations in parallel on a stream Appendix D. Lambdas and JVM bytecode Index List of Figures List of Tables List of Listings
Joshua Bloch is a professor at Carnegie Mellon University. He was formerly the chief Java architect at Google, a distinguished engineer at Sun Microsystems, and a senior systems designer at Transarc. He led the design and implementation of numerous Java platform features, including the JDK 5.0 language enhancements and the Java Collections Framework. He holds a Ph.D. in computer science from Carnegie Mellon University and a B.S. in computer science from Columbia University. He is the author of Effective Java.
“Joshua J. Bloch (born August 28, 1961) is an American software engineer and a technology author, formerly employed at Sun Microsystems and Google. He led the design and implementation of numerous Java platform features, including the Java Collections Framework, the java.math package, and the assert mechanism.[1] He is the author of the programming guide Effective Java (2001), which won the 2001 Jolt Award,[2] and is a co-author of two other Java books, Java Puzzlers (2005) and Java Concurrency In Practice (2006).” (WP)
Bloch has worked as a Senior Systems Designer at Transarc, and later as a Distinguished Engineer at Sun Microsystems. In June 2004, he left Sun and became Chief Java Architect at Google.[5] On August 3, 2012, Bloch announced that he would be leaving Google.[6]
In December 2004, Java Developer’s Journal included Bloch in its list of the “Top 40 Software People in the World”.[7]
Bloch has proposed the extension of the Java programming language with two features: Concise Instance Creation Expressions (CICE) (coproposed with Bob Lee and Doug Lea) and Automatic Resource Management (ARM) blocks. The combination of CICE and ARM formed one of the three early proposals for adding support for closures to Java.[8] ARM blocks were added to the language in JDK7.[9]
Bloch is currently an affiliated faculty member of the Institute for Software Research at Carnegie Mellon University, where he holds the title “Adjunct Professor of the Practice“.[10]
Java has changed dramatically since the previous edition of Effective Java was published shortly after the release of Java 6. This Jolt award-winning classic has now been thoroughly updated to take full advantage of the latest language and library features. The support in modern Java for multiple paradigms increases the need for specific best-practices advice, and this book delivers.
As in previous editions, each chapter of Effective Java, Third Edition, consists of several “items,” each presented in the form of a short, stand-alone essay that provides specific advice, insight into Java platform subtleties, and updated code examples. The comprehensive descriptions and explanations for each item illuminate what to do, what not to do, and why.
The third edition covers language and library features added in Java 7, 8, and 9, including the functional programming constructs that were added to its object-oriented roots. Many new items have been added, including a chapter devoted to lambdas and streams.
New coverage includes
Functional interfaces, lambda expressions, method references, and streams
Default and static methods in interfaces
Type inference, including the diamond operator for generic types
The @SafeVarargs annotation
The try-with-resources statement
New library features such as the Optional interface, java.time, and the convenience factory methods for collections
About the Author:
Joshua Bloch is a professor at Carnegie Mellon University. He was formerly the chief Java architect at Google, a distinguished engineer at Sun Microsystems, and a senior systems designer at Transarc. He led the design and implementation of numerous Java platform features, including the JDK 5.0 language enhancements and the Java Collections Framework. He holds a Ph.D. in computer science from Carnegie Mellon University and a B.S. in computer science from Columbia University.
The #1 Guide to Advanced Java Programming, Fully Updated for Java 11
Core Java has long been recognized as the leading, no-nonsense tutorial and reference for experienced programmers who want to write robust Java code for real-world applications. Now, Core Java, Volume II—Advanced Features, Eleventh Edition, has been updated for Java 11, with up-to-date coverage of advanced UI and enterprise programming, networking, security, and Java’s powerful new module system.
Cay S. Horstmann explores sophisticated new language and library features with the depth and completeness that readers expect from Core Java. He demonstrates how to use these features to build professional-quality applications, using thoroughly tested examples that reflect modern Java style and best practices, including modularization. Horstmann’s examples are carefully crafted for easy understanding and maximum practical value, so you can consistently use them to jump-start your own code.
Master advanced techniques, idioms, and best practices for writing superior Java code
Take full advantage of modern Java I/O APIs, object serialization, and regular expressions
Efficiently connect to network services, implement network clients and servers, and harvest web data
Query databases and manage database connections with the latest version of JDBC
Simplify all aspects of date and time programming with the Java Date and Time API
Write internationalized programs that localize dates, times, numbers, text, and GUIs
Process code in three powerful ways: the scripting API, compiler API, and annotation processing
Learn how to migrate legacy code to the Java Platform Module System
Leverage the modern Java security features most valuable to application programmers
Program advanced client-side user interfaces, and generate images on the server
Use JNI to interoperate with native C code
See Core Java, Volume I—Fundamentals, Eleventh Edition (ISBN-13: 978-0-13-516630-7), for expert coverage of fundamental Java and UI programming, including objects, generics, collections, lambda expressions, Swing design, concurrency, and functional programming.
About the Author:
Cay S. Horstmann is a professor of computer science at San Jose State University and a Java Champion. He is also the author of Core Java, Volume I and Core Java, Volume II, Eleventh Edition, Core Java SE 9 for the Impatient, Second Edition (Addison-Wesley, 2018), and Scala for the Impatient, Second Edition (Addison-Wesley, 2017). He has written more than a dozen other books for professional programmers and computer science students.
The #1 Guide for Serious Programmers: Fully Updated for Java SE 9, 10 & 11
Cay Horstmann’s Core Java, Volume I—Fundamentals, Eleventh Edition, is the definitive guide to writing robust, maintainable code with the Java SE 9, 10, and 11 language and libraries. Horstmann writes for serious programmers who use Java in production projects, and need a deep, practical understanding of the language and API. Throughout, he delivers what you need most: hundreds of real (non-toy) examples revealing the most powerful, effective ways to get the job done.
Updated examples reflect the new var keyword and take advantage of improvements in the Java API. You’ll learn how to use JShell’s new Read-Eval-Print Loop (REPL) for more rapid and exploratory development, and apply new features of the APIs for streams, input/output, processes, and concurrency.
In this first of two volumes, Horstmann offers in-depth coverage of fundamental Java and UI programming, including object-oriented programming, generics, collections, lambda expressions, Swing design, concurrency, and functional programming. If you’re an experienced programmer moving to Java SE 9, 10, or 11, there’s no better source for expert insight, solutions, and code.
Master foundational techniques, idioms, and best practices for writing superior Java code
Efficiently implement encapsulation and inheritance
Use sound principles of object-oriented design
Leverage the full power of objects with interfaces, lambda expressions, and inner classes
Harden programs through effective exception handling and debugging
Write safer, more reusable code with generic programming
Improve performance and efficiency with Java’s standard collections
Build cross-platform GUIs with the Swing toolkit
Fully utilize multicore processors with Java’s improved concurrency
See Core Java, Volume II—Advanced Features, Eleventh Edition (ISBN-13: 978-0-13-516631-4), for expert coverage of Java 9, 10, and 11 enterprise features, the module system, annotations, networking, security, and advanced UI programming.
About the Author:
Cay S. Horstmann is a professor of computer science at San Jose State University and a Java Champion. He is also the author of Core Java, Volume I and Core Java, Volume II, Eleventh Edition, Core Java SE 9 for the Impatient, Second Edition (Addison-Wesley, 2018), and Scala for the Impatient, Second Edition (Addison-Wesley, 2017). He has written more than a dozen other books for professional programmers and computer science students.
Any time you need quick answers for developing or debugging Java programs, this pocket guide is the ideal reference to standard features of the Java programming language and its platform. You’ll find helpful programming examples, tables, figures, and lists fast—including Java 9 features such as modular source code and the new JShell interactive command-line REPL. It’s a handy companion, whether you’re in the office, in the lab, or on the road.
This book also provides material to help you prepare for the Oracle Certified Associate Java Programmer exam.
Quickly find Java language details, such as naming conventions, types, statements and blocks, and object-oriented programming
Get details on the Java SE platform, including development basics, memory management, concurrency, and generics
Use new features in Java 9, including modular source code and JShell
Browse through information on basic input/output, NIO 2.0, the Java collections framework, and the Java Scripting API
Get supplemental references to fluent APIs, third-party tools, and basics of the Unified Modeling Language (UML)
About the Author:
Robert Liguori is an Oracle Certified Java Professional and a software developer / test engineer for several Java-based air traffic management applications. Robert has a Bachelors degree in Computer Science and Information Technology from Richard Stockton College of New Jersey.
“Designed to be your companion, this Pocket Guide provides a quick reference to the standard features of the Java programming language and its platform.
This Pocket Guide provides you with the information you will need while developing or debugging your Java programs, including helpful programming examples, tables, figures, and lists.
Java coverage in this book is representative through Java SE 9 incorporating a subset of the 80+ JDK Enhancement Proposals (JEPs) slated for the release. This Java coverage includes improvements to the generage language as well as coverage of the new Java Shell and the new Java Module System. This book supercedes the three previous versions: Java Pocket Guide, Java 7 Pocket Guide, and Java 8 Pocket Guide.
For uniformity and enhanced interest, the majority of the code examples in this fourth edition of the Java Pocket Guide have been updated from code segments of the Gliesians Web Application. At the time of this writing, the primary focus of the Gliesians Web Application is to provide free utilities relative to genealogy and small unmanned aerial systems.
The material in this book also provides support in preparing for the Oracle Certified Programmer exams. If you are considering pursuing one of the Java certifications, you may also wish to acquire the OCA Java SE 8 Programmer I Study Guide (Exam 1Z0-808) by Edward Finegan and Robert Liguori (McGraw-Hill Osborne Media, 2015).
Table of Contents:
Preface
Book Structure
Conventions Used in This Book
O’Reilly Safari
How to Contact Us
Acknowledgments
I. Language
Java Naming Conventions
Java Acronyms
Java Annotation Names
Java Class Names
Java Constant Names
Java Enumeration Names
Java Generic Type Parameter Names
Java Instance and Static Variable Names
Java Interface Names
Java Method Names
Java Package Names
Java Module Names
Java Parameter and Local Variable Names
Java Lexical Elements
Java Unicode and ASCII
Java Printable ASCII Characters
Java Nonprintable ASCII Characters
Java Compact Strings
Java Comments
Java Keywords
Java Identifiers
Java Separators
Java Operators
Java Literals
Java Boolean Literals
Java Character Literals
Java Integer Literals
Java Floating-Point Literals
Java String Literals
Java Null Literals
Java Escape Sequences
Java Unicode Currency Symbols
Java Fundamental Types
Java Primitive Types
Literals for Primitive Types
Java Floating-Point Entities
Java Operations Involving Special Entities
Java Numeric Promotion of Primitive Types
Java Unary Numeric Promotion
Java Binary Numeric Promotion
Java Special Cases for Conditional Operators
Java Wrapper Classes
Java Autoboxing and Unboxing
Java Autoboxing
Java Unboxing
Java Reference Types
Comparing Java Reference Types to Java Primitive Types
Java Default Values
Java Instance Variable and Java Local Variable Objects
Java Arrays
Conversion of Java Reference Types
Java Widening Conversions
Java Narrowing Conversions
Converting Between Java Primitives and Java Reference Types
Passing Java Reference Types into Java Methods
Comparing Java Reference Types Using the Java Equality Operators
Using the Java equals() Method
Comparing Java Strings
Comparing Java Enumerations
Copying Java Reference Types
Copying a Java Reference to an Java Object
Cloning Java Objects
Shallow and deep cloning of Java objects
Java Memory Allocation and Java Garbage Collection of Java Reference Types
Java Object-Oriented Programming
Java Classes and Java Objects
Java Class Syntax
Instantiating a Java Class (Creating a Java Object)
Java Data Members and Java Methods
Accessing Java Data Members and Java Methods in Java Objects
Java Overloading
Java Overriding
Java Constructors
Java Superclasses and Java Subclasses
The Java this Keyword
Java Variable-Length Argument Lists
Java Abstract Classes and Java Abstract Methods
Java Abstract Classes
Java Abstract Methods
Java Static Data Members, Java Static Methods, Java Static Constants, and Java Static Initializers
Java Static Data Members
Java Static Methods
Java Static Constants
Java Static Initializers
Java Interfaces
Java Enumerations
Java Annotation Types
Built-in Java Annotations
Developer-Defined Java Annotations
Functional Java Interfaces
Java Statements and Blocks
Java Expression Statements
Java Empty Statement
Java Blocks
Java Conditional Statements
The Java if Statement
The Java if else Statement
The Java if else if Statement
The Java switch Statement
Java Iteration Statements
The Java for Loop
The Java Enhanced for Loop
The Java while Loop
The Java do while Loop
Java Transfer of Control
The Java break Statement
The Java continue Statement
The Java return Statement
Java Synchronized Statement
Java Assert Statement
Java Exception Handling Statements
Java Exception Handling
The JavaException Hierarchy
Java Checked Exceptions and Java Unchecked Exceptions and Java Errors
Java Checked Exceptions
Java Unchecked Exceptions
Java Errors
Common Java Checked/Unchecked Exceptions and Java Errors
Common Java Checked Exceptions
Common Java Unchecked Exceptions
Common Java Errors
Java Exception Handling Keywords
The Java throw Keyword
The Java try/catch/finally Keywords
The Java try-catch Statement
The Java try-finally Statement
The Java try-catch-finally Statement
The Java try-with-resources Statement
The Java multi-catch Clause
The Java Exception Handling Process
Defining Your Own Java Exception Class
Printing Information About Java Exceptions
The Java getMessage() Method
The Java toString() Method
The Java printStackTrace() Method
Java Modifiers
Java Access Modifiers
Other Java (Nonaccess) Modifiers
Java Modifiers Encoding
II. Platform
Java Platform, Standard Edition Common Java SE API Libraries Language and Utility Libraries
Base Libraries
Integration Libraries
Miscellaneous User Interface Libraries
JavaFX User Interface Library
Remote Method Invocation (RMI) and CORBA Libraries
Security Libraries
Extensible Markup Language (XML) Libraries
Development Basics Java Runtime Environment
Java Development Kit
Java Program Structure
Command-Line Tools Java Compiler
Java Interpreter
Java Program Packager
JAR File Execution
Classpath
Memory Management Garbage Collectors Serial Collector
Parallel Collector
Parallel Compacting Collector
Concurrent Mark-Sweep Collector
Garbage-First (G1) Collector
Memory Management Tools
Command-Line Options
Resizing the JVM Heap
Metaspace
Interfacing with the GC Explicit Garbage Collection
Finalization
Basic Input and Output Standard Streams in, out, and err
Class Hierarchy for Basic Input and Output
File Reading and Writing Reading Character Data from a File
Reading Binary Data from a File
Writing Character Data to a File
Writing Binary Data to a File
Socket Reading and Writing Reading Character Data from a Socket
Reading Binary Data from a Socket
Writing Character Data to a Socket
Writing Binary Data to a Socket
Serialization Serialize
Deserialize
Zipping and Unzipping Files Compressing and Uncompressing GZIP Files
New I/O API (NIO.2) The Path Interface
The Files Class
Additional Features
Concurrency Creating Threads Extending the Thread Class
Implementing the Runnable Interface
Thread States
Thread Priorities
Common Methods
Synchronization
Concurrent Utilities Executors
Concurrent Collections
Synchronizers
Timing Utility
Java Collections Framework The Collection Interface
Implementations
Collection Framework Methods
Collections Class Algorithms
Algorithm Efficiencies
Comparator Functional Interface
Convenience Factory Methods
Generics Framework Generic Classes and Interfaces
Constructors with Generics
Substitution Principle
Type Parameters, Wildcards, and Bounds
The Get and Put Principle
Generic Specialization
Generic Methods in Raw Types
The Java Scripting API Scripting Languages
Script Engine Implementations Embedding Scripts into Java
Invoking Methods of Scripting Languages
Accessing and Controlling Java Resources from Scripts
Setting Up Scripting Languages and Engines Scripting Language Setup
Scripting Engine Setup
Scripting Engine Validation
Date and Time API Legacy Interoperability
Regional Calendars
ISO Calendar Machine Interface
Durations and Periods
JDBC and XSD Mapping
Formatting
Lambda Expressions λEs Basics λEs Syntax and Example
This updated edition of Java in a Nutshell not only helps experienced Java programmers get the most out of Java versions 9 through 11, it’s also a learning path for new developers. Chock full of examples that demonstrate how to take complete advantage of modern Java APIs and development best practices, this thoroughly revised book includes new material on Java Concurrency Utilities.
The book’s first section provides a fast-paced, no-fluff introduction to the Java programming language and the core runtime aspects of the Java platform. The second section is a reference to core concepts and APIs that explains how to perform real programming work in the Java environment.
Get up to speed on language details, including Java 9-11 changes
Learn object-oriented programming, using basic Java syntax
Explore generics, enumerations, annotations, and lambda expressions
Understand basic techniques used in object-oriented design
Examine concurrency and memory, and how they’re intertwined
Work with Java collections and handle common data formats
Delve into Java’s latest I/O APIs, including asynchronous channels
Use Nashorn to execute JavaScript on the Java Virtual Machine
Become familiar with development tools in OpenJDK
About the Authors:
Ben Evans is an author, speaker, consultant and educator. He is co-founder of jClarity, a startup which delivers performance tools & services to help development & ops teams. He helps to organize the London Java Community and serves on the Java Community Process Executive Committee, helping define standards for the Java ecosystem. He is a Java Champion, JavaOne Rockstar Speaker and a Java Editor at InfoQ. Ben travels frequently and speaks regularly, all over the world.
David Flanagan is a computer programmer who spends most of his time writing about JavaScript and Java. His books with O’Reilly include Java in a Nutshell, Java Examples in a Nutshell, Java Foundation Classes in a Nutshell, JavaScript: The Definitive Guide, and JavaScript Pocket Reference. David has a degree in computer science and engineering from the Massachusetts Institute of Technology. He lives with his wife and children in the U.S. Pacific Northwest bewteen the cities of Seattle, Washington and Vancouver, British Columbia. David has a blog at www.davidflanagan.com.