Introduction

Java is good stuff. I’ve been using it for years. I like Java because it’s very orderly. Almost everything follows simple rules. The rules can seem intimidating at times, but this book is here to help you figure them out. So, if you want to use Java and want an alternative to the traditional techie, soft-cover book, sit down, relax, and start reading Java For Dummies, 6th Edition.

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 let me 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.

So, in this book, I divide Java 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 Java For Dummies, 6th Edition, is no exception. What follows is a brief explanation of the typefaces used in this book:

  • New terms are set in italics.
  • If you need to type something that’s mixed in with the regular text, the characters you type appear in bold. For example: “Type MyNewProject in the text field.”
  • You also see this computerese font. I use computerese for Java code, filenames, web page addresses (URLs), onscreen messages, and other such things. Also, if something you need to type is really long, it appears in computerese font on its own line (or lines).
  • You need to change certain things when you type them on your own computer keyboard. For instance, I may ask you to type

    public class Anyname

    which means that you type public class and then some name that you make up on your own. Words that you need to replace with your own words are set in italicized computerese.

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 that you can follow:

  • If you already know what kind of an animal Java is and know that you want to use Java, skip Chapter 1 and go straight to Chapter 2. Believe me, I won’t mind.
  • If you already know how to get a Java program running, and you don’t care what happens behind the scenes when a Java program runs, then skip Chapter 2 and start with Chapter 3.
  • If you write programs for a living but use any language other than C or C++, start with Chapter 2 or 3. When you reach Chapters 5 and 6, you’ll probably find them to be easy reading. When you get to Chapter 7, it’ll be time to dive in.
  • If you write C (not C++) programs for a living, start with Chapters 2, 3, and 4 but just skim Chapters 5 and 6.
  • If you write C++ programs for a living, glance at Chapters 2 and 3, skim Chapters 4 through 6, and start reading seriously in Chapter 7. (Java is a bit different from C++ in the way it handles classes and objects.)
  • If you write Java programs for a living, come to my house and help me write Java For Dummies, 7th Edition.

If you want to skip the sidebars and the Technical Stuff icons, please do. In fact, if you want to skip anything at all, feel free.

Foolish Assumptions

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 the good news: You can run most of the code in this book on almost any computer. The only computers that you can’t use to run this code are ancient things that are more than ten years old (give or take a few years).
  • I assume that you can navigate through 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 your 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, consult a book with instructions tailored to your system.

  • I assume that you can think logically. That’s all there is to programming in Java — 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 make very few assumptions about your computer programming experience (or your lack of such experience). In writing this book, I’ve tried to do the impossible. I’ve tried to make the book interesting for experienced programmers, yet accessible to people with little or no programming experience. This means that I don’t assume any particular programming background on your part. If you’ve never created a loop or indexed an array, that’s okay.

    On the other hand, if you’ve done these things (maybe in Visual Basic, COBOL, or C++), you’ll discover some interesting plot twists in Java. The developers of Java took the best ideas in object-oriented programming, streamlined them, reworked them, and reorganized them into a sleek, powerful way of thinking about problems. You’ll find many new, thought-provoking features in Java. As you find out about these features, many of them will seem very natural to you. One way or another, you’ll feel good about using Java.

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 I: Getting Started with Java

This part is your complete, executive briefing on Java. It includes some “What is Java?” material and a jump-start chapter — Chapter 3. In Chapter 3, you visit the major technical ideas and dissect a simple program.

Part II: Writing Your Own Java Program

Chapters 4 through 6 cover the fundamentals. These chapters describe the things that you need to know so you can get your computer humming along.

If you’ve written programs in Visual Basic, C++, or any another language, some of the material in Part II may be familiar to you. If so, you can skip some sections or read this stuff quickly. But don’t read too quickly. Java is a little different from some other programming languages, especially in the things that I describe in Chapter 4.

Part III: Working with the Big Picture: Object-Oriented Programming

Part III has some of my favorite chapters. This part covers the all-important topic of object-oriented programming. In these chapters, you find out how to map solutions to big problems. (Sure, the examples in these chapters aren’t big, but the examples involve big ideas.) In bite-worthy increments, you discover how to design classes, reuse existing classes, and construct objects.

Have you read any of those books that explain object-oriented programming in vague, general terms? I’m very proud to say that Java For Dummies, 6th Edition, isn’t like that. In this book, I illustrate each concept with a simple-yet-concrete program example.

Part IV: Savvy Java Techniques

If you’ve tasted some Java and want more, you can find what you need in this part of the book. This part’s chapters are devoted to details — the things that you don’t see when you first glance at the material. So, after you read the earlier parts and write some programs on your own, you can dive in a little deeper by reading Part IV.

Part V: The Part of Tens

The Part of Tens is a little Java candy store. In the Part of Tens, you can find lists — lists of tips for avoiding mistakes, for finding resources, and for all kinds of interesting goodies.

Icons Used in This Book

If you could watch me write this book, you’d see me sitting at my computer, talking to myself. I say each sentence in my head. Most of the sentences I mutter several times. When I have an extra thought, a side comment, or something that doesn’t belong in the regular stream, I twist my head a little bit. That way, whoever’s listening to me (usually nobody) knows that I’m off on a momentary tangent.

Of course, in print, you can’t see me twisting my head. I need some other way of setting a side thought in a corner by itself. I do it with icons. When you see a Tip icon or a Remember icon, you know that I’m taking a quick detour.

Here’s a list of icons that I use in this book:

tip.eps A tip is an extra piece of information — something helpful that the other books may forget to tell you.

warning.eps Everyone makes mistakes. Heaven knows that I’ve made a few in my time. Anyway, when I think people are especially prone to make a mistake, I mark it with a Warning icon.

remember.eps Question: What’s stronger than a Tip, but not as strong as a Warning?

Answer: A Remember icon.

cross-reference.eps “If you don’t remember what such-and-such means, see blah-blah-blah,” or “For more information, read blahbity-blah-blah.

ontheweb_fmt.eps This icon calls attention to useful material that you can find online. (You don’t have to wait long to see one of these icons. I use one at the end of this introduction!)

technicalstuff.eps Occasionally, I run across a technical tidbit. The tidbit may help you understand what the people behind the scenes (the people who developed Java) were thinking. You don’t have to read it, but you may find it useful. You may also find the tidbit helpful if you plan to read other (more geeky) books about Java.

Beyond the Book

I’ve written a lot of extra content that you won’t find in this book. Go online to find the following:

  • Cheat Sheet: Check out www.dummies.com/cheatsheet/java.
  • Online Articles: On several of the pages that open each of this book’s parts, you can find links to what the folks at For Dummies call Web Extras, which expand on some concept I’ve discussed in that particular section. You can find them at www.dummies.com/extras/java.

Where to Go from Here

If you’ve gotten this far, you’re ready to start reading about Java application development. Think of me (the author) as your guide, your host, your personal assistant. I do everything I can to keep things interesting and, most importantly, to help you understand.

ontheweb_fmt.eps If you like what you read, send me a note. My e-mail address, which I created just for comments and questions about this book, is [email protected]. If e-mail and chat aren’t your favorites, you can reach me instead on Twitter (@allmycode) and on Facebook (www.facebook.com/allmycode). And don’t forget — for the latest updates, visit this book’s website. The site’s address is www.allmycode.com/JavaForDummies.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.133.180