Iuliana Cosmina
Java for Absolute Beginners Learn to Program the Fundamentals the Java 9+ Way
Iuliana Cosmina
Edinburgh, UK
Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub via the books product page, located at www.apress.com/9781484237779 . For more detailed information, please visit http://www.apress.com/source-code .
ISBN 978-1-4842-3777-9 e-ISBN 978-1-4842-3778-6
https://doi.org/10.1007/978-1-4842-3778-6
Library of Congress Control Number: 2018964482
Iuliana Cosmina 2018
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein.
Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.com, or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.
This book is dedicated to all men that told me software engineering is not for women.
And to that one professor that told me Im not PhD material.
How do ya like them apples?
Introduction
Even though I have been writing Java Applications since 2002 I dont think Ive ever dived so deeply into the JVM as I did while writing this book. Most companies Ive worked for had their own code base when I joined them, and my work was mostly related to designing, improving or maintaining one that already existed. Its like making brownies when you already have brownie mix. Writing this book has given me the opportunity to get down to basics and work with basic ingredientsso, making brownies using eggs, flower, cocoa, milk, and butter.
Java began in 1982 and was created by a handful of people. The most renowned name linked to the beginning of Java is James Gosling, also known as the father of Java, the language that is now used on over three billion devices. When Oracle bought Sun Microsystems, developers were worried about Javas future, especially since its main creator quit the company and went on to create what was thought to be Javas replacement: Scala. That will probably never happen. Java is still here.
Most banking applications are written in Java and because it is definitely dangerous and costly to migrate these applications, Java will be here in 50 years, if not more. Java began by making websites more dynamic and more entertaining, and ended up being the basis for applications run on ATMs, cashier machines, computers, and mobile devices. Sure, this would have been more difficult if Java wasnt cross-platform.
The first Java version was officially released in 1996. Since then, ten more versions have been released, with the latest one, Java 11, being released on 25th September 2018. The work on Java 12 has already begun and the early access build is already available.
This book was written with the intention to cover the fundamental elements of the language and of the JVM, especially the ones introduced in versions 9, 10, and 11. The book provides a complete overview of the most important Java classes in the JVM, all wrapped up in a multimodule project that compiles with Java 11 and Gradle 5. A group of reviewers has gone over the book, but if you notice any inconsistencies, please send an email to editorial@apress.com , or directly to the author, and corrections will be made and published in an erratum that will be uploaded to the official GitHub repository for the book. The example source code for this book can be found on GitHub or downloaded from the official books product page, located at www.apress.com/in/book/9781484237779 .
I truly hope you will enjoy using this book to learn Java as much as I enjoyed writing it.
Acknowledgments
Here I am again, the main author of a technical book for the third time.
This book was quite challenging to write, because I had to quickly adapt to changes made to the Java ecosystem. With the new six months interval release system, modules being introduced, and backward compatibility thrown out the window, I found myself with a project that stopped compiling and had to invest precious time into fixing it, understand why it broke in the first place, and eventually adapt the book.
Writing books for beginners is tricky, because as an experienced developer, it might be difficult to find the right examples and explain them in such a way that even a non-technical person would easily understand them. That is why I am profoundly grateful to Matthew Moodie and Mark Powers for all the support and advice they provided to keep this book at beginner level. We have been working together for four years and it has been a fruitful collaboration so far.
I would like to thank Wallace Jackson; his recommendations and corrections were crucial for the final form of the book.
Apress has published many of the books that I have read and used to improve myself professionally. It is a great honor to publish my fourth book with Apress, and it gives me enormous satisfaction to be able to contribute to the making of a new generation of Java developers.
I am grateful to all my friends who had the patience to listen to me complain about sleepless nights and writers block. Thank you all for being supportive and making sure I still had some fun while writing this book. You have no idea how dear you are to me.
I am thankful to John Mayer still, as his music provided yet again, a great environment for my working nights.
A special thank you to Achim Wagner, whom I consider both a mentor and a dear friend. He provided me with an environment and support to grow as a professional and as a person, and I will miss working with him.
A special thank you to the Bogza-Vlad family: Monica, Tinel, Cristina, and Stefan. You are all close to my heart and this book might have been released later without your support when I moved to Edinburgh.