Barry Burd, PhD, has been a professor in the Department of Mathematics and Computer Science at Drew University since 1980. He has lectured at conferences in the United States, Europe, Australia, and Asia, and hosts podcasts on various software and technology topics. Dr. Burd also authored Java Programming for Android Developers For Dummies.
What's your story?
- Are you a working stiff, interested in knowing more about the way your company's computers work?
- Are you a student who needs some extra reading in order to survive a beginning computer course?
- Are you a typical computer user - you've done lots of word processing and you want to do something more interesting with your computer?
- Are you a job seeker with an interest in entering the fast-paced, glamorous, high-profile world of computer programming (or, at least, the decent-paying world of computer programming)?
Well, if you want to write computer programs, this book is for you. This book avoids the snobby "of-course-you-already-know" assumptions and describes computer programming from scratch.
About This Book
The book uses Java - a powerful, general-purpose computer programming language. But Java's subtleties and eccentricities aren't the book's main focus. Instead, this book emphasizes a process - the process of creating instructions for a computer to follow. Many highfalutin books describe the mechanics of this process - the rules, the conventions, and the formalisms. But those other books aren't written for real people. Those books don't take you from where you are to where you want to be.
In this book, I assume very little about your experience with computers. As you read each section, you get to see inside my head. You see the problems that I face, the things that I think, and the solutions that I find. Some problems are the kind that I remember facing when I was a novice; other problems are the kind that I face as an expert. I help you understand, I help you visualize, and I help you create solutions on your own. I even get to tell a few funny stories.
How to Use This Book
I wish I could say, "Open to a random page of this book and start writing Java code. Just fill in the blanks and don't look back." In a sense, this is true. You can't break anything by writing Java code, so you're always free to experiment.
But I have to be honest: If you don't understand the bigger picture, writing a program is difficult. That's true with any computer programming language - not just Java. If you're typing code without knowing what it's about, and the code doesn't do exactly what you want it to do, you're just plain stuck.
In this book, I divide programming into manageable chunks. Each chunk is (more or less) a chapter. You can jump in anywhere you want - Chapter 5, Chapter 10, or wherever. You can even start by poking around in the middle of a chapter. I've tried to make the examples interesting without making one chapter depend on another. When I use an important idea from another chapter, I include a note to help you find your way around.
In general, my advice is as follows:
- If you already know something, don't bother reading about it.
- If you're curious, don't be afraid to skip ahead. You can always sneak a peek at an earlier chapter, if you really need to do so.
Conventions Used in This Book
Almost every technical book starts with a little typeface legend, and Beginning Programming with Java For Dummies, 5th Edition, is no exception. What follows is a brief explanation of the typefaces used in this book:
What You Don't Have to Read
Pick the first chapter or section that has material you don't already know and start reading there. Of course, you may hate making decisions as much as I do. If so, here are some guidelines you can follow:
- If you already know what computer programming is all about, skip the first half of Chapter 1. Believe me, I won't mind.
If you're required to use a development environment other than Eclipse, you can skip Chapter 2. This applies if you plan to use NetBeans, IntelliJ IDEA, or a number of other development environments.
Most of this book's examples require Java 5.0 or later, and some of the examples require Java 7 or later. So make sure that your system uses Java 7 or later. If you're not sure about your computer's Java version or if you have leeway in choosing a development environment, your safest move is to read Chapter 3.
- If you've already done a little computer programming, be prepared to skim Chapters 6, 7, and 8. Dive fully into Chapter 9 and see whether it feels comfortable. (If so, read on. If not, skim Chapters 6, 7, and 8 again.)
- If you feel comfortable writing programs in a language other than Java, this book isn't for you. Keep this book as a memento and buy my Java For Dummies, 7th Edition (also published by Wiley).
If you want to skip the sidebars and the material highlighted by a Technical Stuff icon, please do. In fact, if you want to skip anything at all, feel free.
In this book, I make a few assumptions about you, the reader. If one of these assumptions is incorrect, you're probably okay. If all these assumptions are incorrect . well, buy the book anyway.
- I assume that you have access to a computer. Here's good news. You can run the code in this book on almost any computer. The only computers you can't use to run this code are ancient things that are more than eight years old (give or take a few years). You can run the latest version of Java on Windows, Macintosh, and Linux computers.
I assume that you can navigate your computer's common menus and dialog boxes. You don't have to be a Windows, Linux, or Macintosh power user, but you should be able to start a program, find a file, put a file into a certain directory - that sort of thing. Most of the time, when you practice the stuff in this book, you're typing code on your keyboard, not pointing and clicking the mouse.
On those rare occasions when you need to drag and drop, cut and paste, or plug and play, I guide you carefully through the steps. But your computer may be configured in any of several billion ways, and my instructions may not quite fit your special situation. So when you reach one of these platform-specific tasks, try following the steps in this book. If the steps don't quite fit, send me an email message or consult a book with instructions tailored to your system.
- I assume that you can think logically. That's all there is to computer programming - thinking logically. If you can think logically, you've got it made. If you don't believe that you can think logically, read on. You may be pleasantly surprised.
- I assume that you know little or nothing about computer programming. This isn't one of those "all things to all people" books. I don't please the novice while I tease the expert. I aim this book specifically toward the novice - the person who has never programmed a computer or has never felt comfortable programming a computer. If you're one of these people, you're reading the right book.
How This Book Is Organized
This book is divided into subsections, which are grouped into sections, which come together to make chapters, which are lumped finally into five parts. (When you write a book, you get to know your book's structure pretty well. After months of writing, you find yourself dreaming in sections and chapters when you go to bed at night.) The parts of the book are listed here.
Part 1: Getting Started with Java Programming
The chapters in Part 1 prepare you for the overall programming experience. In these chapters, you find out what programming is all about and get your computer ready for writing and testing programs.
Part 2: Writing Your Own Java Programs
This part covers the basic building blocks - the elements in any Java program and in any program written using a Java-like language. In this part, you discover how to represent data and how to get new values from existing values. The program examples are short, but cute.
Part 3: Controlling the Flow
Part 3 has some of my favorite chapters. In these chapters, you make the computer navigate from one part of your program to another. Think of your program as a big mansion, with the computer moving from room to room. Sometimes the computer chooses between two or more hallways, and sometimes the computer revisits rooms. As a...