Preface to The Java Tutorial: A Short Course on the Basics, Sixth Edition
Since the acquisition of Sun Microsystems by Oracle Corporation in early 2010, it has been an exciting time for the Java language. As evidenced by the activities of the Java Community Process program, the Java language continues to evolve. The publication of this sixth edition of The Java® Tutorial reflects version 8 of the Java Platform Standard Edition (Java SE) and references the Application Programming Interface (API) of that release.
This edition introduces new features added to the platform since the publication of the fifth edition (under release 7):
- Lambda expressions enable you to treat functionality as a method argument or code as data. Lambda expressions let you express instances of single-method interfaces (referred to as functional interfaces) more compactly. See the new section in Chapter 4, “Lambda Expressions.”
- Type annotations can be used in conjunction with pluggable type systems for improved type checking, and repeating annotations enable the application of the same annotation to a declaration or type use. See the new sections in Chapter 5, “Type Annotations and Pluggable Type Systems” and “Repeating Annotations.”
- Default methods are methods in an interface that have an implementation. They enable new functionality to be added to the interfaces of libraries and ensure binary compatibility with code written for older versions of those interfaces. See the new section in Chapter 6, “Default Methods.”
- Aggregate operations enable you to perform functional-style operations on streams of elements—in particular, bulk operations on collections such as sequential or parallel map-reduce transformations. See the new section in Chapter 12, “Aggregate Operations.”
- Improvements have been added that focus on limiting attackers from using malicious applets and rich Internet applications (RIAs). See the following new and updated sections:
- Chapter 16, “Packaging Programs in JAR Files”
- Chapter 19, “Security in Rich Internet Applications” and “Guidelines for Securing Rich Internet Applications”
- Chapter 20, “Deployment Best Practices”
- Date-Time APIs enable you to represent dates and times and manipulate date and time values. They support the International Organization for Standardization (ISO) calendar system as well as other commonly used global calendars. See the new Chapter 21.
If you plan to take one of the Java SE 8 certification exams, this book can help. The appendix, “Preparation for Java Programming Language Certification,” lists the three exams that are available, detailing the items covered by each exam, cross-referenced to places in the book where you can find more information about each topic. Note that this is one source, among others, that you will want to use to prepare for your exam. Check the online tutorial for the latest certification objectives and cross-references to sections of the tutorial.
All of the material has been thoroughly reviewed by members of Oracle Java engineering to ensure that the information is accurate and up to date. This book is based on the online tutorial hosted on Oracle Corporation’s web site at the following URL:
The information in this book, often referred to as “the core tutorial,” is required by most beginning to intermediate programmers. Once you have mastered this material, you can explore the rest of the Java platform documentation on the web site. If you are interested in developing sophisticated RIAs, check out JavaFX, the Java graphical user interface (GUI) toolkit, which comes with the Java SE Development Kit (JDK). To learn more, see Chapter 22, “Introduction to JavaFX.”
As always, our goal is to create an easy-to-read, practical programmers’ guide to help you learn how to use the rich environment provided by Java to build applications, applets, and components. Go forth and program!
Who Should Read This Book?
This book is geared toward both novice and experienced programmers:
- New programmers can benefit most from reading the book from beginning to end, including the step-by-step instructions for compiling and running your first program in Chapter 1, “Getting Started.”
- Programmers experienced with procedural languages such as C may want to start with the material on object-oriented concepts and features of the Java programming language.
- Experienced programmers may want to jump feet first into the more advanced topics, such as generics, concurrency, or deployment.
This book contains information to address the learning needs of programmers with various levels of experience.
How to Use This Book
This book is designed so you can read it straight through or skip around from topic to topic. The information is presented in a logical order, and forward references are avoided wherever possible.
The examples in this book are compiled against the JDK 8 release. You need to download this release (or later) in order to compile and run most examples.
Some material referenced in this book is available online—for example, the downloadable examples, the solutions to the questions and exercises, the JDK 8 guides, and the API specification.
You will see footnotes like the following:
The Java documentation home on the Oracle web site is at the following location:
To locate the footnoted files online, prepend the URL for the Java documentation home:
The Java Tutorials are also available in two eBook formats:
- mobi eBook files for Kindle
- ePub eBook files for iPad, Nook, and other devices that support the ePub format
Each eBook contains a single trail that is equivalent to several related chapters in this book. You can download the eBooks via the link “In Book Form” on the home page for the Java Tutorials:
We welcome feedback on this edition. To contact us, please see the tutorial feedback page:
This book would not be what it is without the Oracle Java engineering team who tirelessly reviews the technical content of our writing. For this edition of the book, we especially want to thank Alan Bateman, Alex Buckley, Stephen Colebourne, Joe Darcy, Jeff Dinkins, Mike Duigou, Brian Goetz, Andy Herrick, Stuart Marks, Thomas Ng, Roger Riggs, Leif Samuelsson, and Daniel Smith.
Illustrators Jordan Douglas and Dawn Tyler created our professional graphics quickly and efficiently.
Editors Janet Blowney, Deborah Owens, and Susan Shepard provided careful and thorough copyedits of our JDK 8 work.
Thanks for the support of our team: Devika Gollapudi, Ram Goyal, and Alexey Zhebel.
Last but not least, thanks for the support of our management: Sowmya Kannan, Sophia Mikulinsky, Alan Sommerer, and Barbara Ramsey.
About the Authors
Raymond Gallardo is a senior technical writer at Oracle Corporation. His previous engagements include college instructor, technical writer for IBM, and bicycle courier. He obtained his BSc in computer science and English from the University of Toronto and MA in creative writing from the City College of New York.
Scott Hommel is a senior technical writer at Oracle Corporation, where he documents Java SE. For the past fifteen years, he has written tutorials, technical articles, and core release documentation for Java SE and related technologies.
Sowmya Kannan wears many hats on the Java SE documentation team, including planning, writing, communicating with developer audiences, and tinkering with production tools. She has more than fifteen years of experience in the design, development, and documentation of the Java platform, Java-based middleware, and web applications.
Joni Gordon is a principal technical writer at Oracle Corporation. She has contributed to the documentation for Java SE and JavaFX. She has been a technical writer for more than fifteen years and has a background in enterprise application development.
Sharon Biocca Zakhour was previously a principal technical writer on staff at Oracle Corporation and formerly at Sun Microsystems. She has contributed to Java SE documentation for more than twelve years, including The Java™ Tutorial, Fourth Edition, and The JFC Swing Tutorial, Second Edition. She graduated from UC Berkeley with a BA in computer science and has worked as a programmer, developer support engineer, and technical writer for thirty years.