Introduction

Welcome to Java All-in-One For Dummies, 6th Edition — the one Java book that’s designed to replace an entire shelf full of the dull, tedious titles you’d otherwise have to buy. This book contains all the basic information you need to know to get going with Java programming, starting with writing statements and using variables and ending with techniques for writing programs that use animation and play games. Along the way, you find plenty of not-so-basic information about programming user interfaces, working with classes and objects, creating web applications, and dealing with files and databases.

You can (and probably should, eventually) buy separate books on each of these topics. It won’t take long before your bookshelf is bulging with 10,000 or more pages of detailed information about every imaginable nuance of Java programming. But before you’re ready to tackle each of those topics in depth, you need to get a bird’s-eye picture. That’s what this book is about.

And if you already own 10,000 pages or more of Java information, you may be overwhelmed by the amount of detail and wonder, “Do I really need to read 1,200 pages about JSP just to create a simple web page? And do I really need a six-pound book on JavaFX?” Truth is, most 1,200-page programming books have about 200 pages of really useful information — the kind you use every day — and about 1,000 pages of excruciating details that apply mostly if you’re writing guidance-control programs for nuclear missiles or trading systems for the New York Stock Exchange.

The basic idea here is that I’ve tried to wring out the 100-or-so most useful pages of information on these different Java programming topics: setup and configuration, basic programming, object-oriented programming, advanced programming techniques, JavaFX, file and database programming, web programming, and animation and game programming. Thus you get a nice, trim book.

So whether you’re just getting started with Java programming or you’re a seasoned pro, you’ve found the right book.

About This Book

Java All-in-One For Dummies, 6th Edition, is a reference for all the great things (and maybe a few not-so-great things) that you may need to know when you’re writing Java programs. You can, of course, buy a huge 1,200-page book on each of the programming topics covered in this book. But then, who would carry them home from the bookstore for you? And where would you find the shelf space to store them? And when will you find the time to read them?

In this book, all the information you need is conveniently packaged for you in-between one set of covers. And all of the information is current for the newest release of Java, known as JDK 14. This book doesn’t pretend to be a comprehensive reference for every detail on every possible topic related to Java programming. Instead, it shows you how to get up and running fast so that you have more time to do the things you really want to do. Designed using the easy-to-follow For Dummies format, this book helps you get the information you need without laboring to find it.

Java All-in-One For Dummies, 6th Edition, is a big book made up of nine smaller books — minibooks, if you will. Each of these minibooks covers the basics of one key element of programming, such as installing Java and compiling and running programs, or using basic Java statements, or using JavaFX to write GUI applications.

Whenever one big thing is made up of several smaller things, confusion is always a possibility. That’s why this book has multiple access points. At the beginning is a detailed table of contents that covers the entire book. Then each minibook begins with a minitable of contents that shows you at a miniglance what chapters are included in that minibook. Useful running heads appear at the top of each page to point out the topic discussed on that page. And handy thumbtabs run down the side of the pages to help you find each minibook quickly. Finally, a comprehensive index lets you find information anywhere in the entire book.

Foolish Assumptions

You and I have never met, so it is difficult for me to make any assumptions about why you are interested in this book. However, let’s start with a few basic assumptions:

  • You own or have access to a relatively modern computer. The examples were created on a Windows computer, but you can learn to program in Java just as easily on a Mac or Linux computer.
  • You’re an experienced computer user. In other words, I assume that you know the basics of using your computer, such as starting programs and working with the file system.
  • You’re interested in learning how to write programs in the Java language. Since that’s what this book teaches, it’s a fair assumption.

I do not make any assumptions about any previous programming experience in Java or in any other programming language. Nor do I make any assumptions about why you want to learn about Java programming. There are all sorts of valid reasons for learning Java. Some want to learn Java for professional reasons; maybe you want to become a professional Java programmer, or maybe you are a C# or C++ programmer who occasionally needs to work in Java. On the other hand, maybe you think programming in Java would make an interesting hobby.

Regardless of your motivation, I do assume that you are a reasonably intelligent person. You don’t have to have a degree in advanced physics, or a degree in anything at all for that matter, to master Java programming. All you have to be is someone who wants to learn and isn’t afraid to try.

Icons Used in This Book

Like any For Dummies book, this book is chock-full of helpful icons that draw your attention to items of particular importance. You find the following icons throughout this book:

Warning Danger, Will Robinson! This icon highlights information that may help you avert disaster.

Remember Did I tell you about the memory course I took?

Tip Pay special attention to this icon; it lets you know that some particularly useful tidbit is at hand.

Technical Stuff Hold it — overly technical stuff is just around the corner. Obviously, because this is a programming book, almost every paragraph of the next 900 or so pages could get this icon. So I reserve it for those paragraphs that go into greater depth, down into explaining how something works under the covers — probably deeper than you really need to know to use a feature, but often enlightening.

Beyond the Book

In addition to the material in the print or e-book you’re reading right now, this product also comes with some access-anywhere goodies on the web. Check out the free Cheat Sheet for more on Java. To get this Cheat Sheet, simply go to www.dummies.com and type Java All-in-One For Dummies Cheat Sheet in the Search box.

Visit www.dummies.com/go/javaaiofd6e to dive even deeper into Java. You can find and download the code used in the book at that link. You can also download a bonus minibook covering how to use Java with files and databases.

Where to Go from Here

This isn’t the kind of book you pick up and read from start to finish, as if it were a cheap novel. If I ever see you reading it at the beach, I’ll kick sand in your face. Beaches are for reading romance novels or murder mysteries, not programming books. Although you could read straight through from start to finish, this book is a reference book, the kind you can pick up, open to just about any page, and start reading. You don’t have to memorize anything in this book. It’s a “need-to-know” book: You pick it up when you need to know something. Need a reminder on the constructors for the ArrayList class? Pick up the book. Can’t remember the goofy syntax for anonymous inner classes? Pick up the book. After you find what you need, put the book down and get on with your life.