Becoming a Java Programmer
See all Sams Teach Yourself on InformIT Programming Tutorials.
Java programming is a lot easier than it looks. I'm not supposed to tell anyone that, because there are thousands of programmers who have used their Java skills to get high-paying jobs in software development, Internet programming, and e-commerce. The last thing any of them wants is for the boss to know that anyone with persistence and a little free time can learn the language, the most popular programming language in use today.
Java is one of the best languages to learn because it's a useful, powerful, modern technology that's being used by thousands of programmers around the world.
“Sams Teach Yourself Java 2 in 24 Hours” teaches Java programming from the grounds up. It introduces the concepts in English instead of jargon, with plenty of step-by-step examples of working programs. Spend 24 hours with the book and you'll be writing your own Java programs, confident in your ability to use the language and learn more about it. You also will have skills in areas that are becoming increasingly important — network computing, graphical user interface design, and object-oriented programming.
— Rogers Cadenhead
Computer programming is insanely difficult. It requires a four-year degree in computer science, thousands of dollars in computer hardware and software, a keen analytical intellect, the patience of Job, and a strong liking for caffeinated drinks. If you're a programming novice, this is probably what you've heard about computer programming. Aside from the part about caffeine, all of the rumors are greatly exaggerated.
Programming is a lot easier than most people think, although there are several reasons why you might believe otherwise:
Computer programmers have been telling people for years that programming is hard. This belief makes it easier for us to find high-paying jobs (or so I've heard), and gives us more leeway to goof off during business hours.
Computer programming manuals are often written in a language that only a Scrabble player could appreciate. Strange acronyms like OOP, RAD, COM, and MUMPS are used frequently along with newly invented jargon like instantiation, bytecode, and makefile.
Many computer programming languages have been available only with software packages costing $200 or more, which is a lot of cabbage.
Because of the growth of the Internet and other factors, this is a great time to learn programming. Useful programming tools are being made available at low cost (or no cost), often as downloads from World Wide Web sites. Thousands of programmers are distributing their work under "open source" licenses so people can examine how the programs were written, correct errors, and add their own improvements.
The goal of this book is to teach programming to the person who has never tried to program before, or the person who tried programming but hated it with an intense passion. The English language will be used as much as possible instead of jargon and obscure acronyms, and all new programming terms will be thoroughly explained as they are introduced.
If I've succeeded, you will finish Sams Teach Yourself Java 2 in 24 Hours with enough programming skill to be a danger to yourself and others. You'll be able to write programs, dive into other programming books with more confidence, and learn programming languages more easily. You also will have developed skills with Java, the most exciting programming language to be introduced in a decade.
The first hour of this book provides some introductory material about programming and gives you instructions on how to set up your computer so you can write Java programs. The following topics will be covered:
Choosing which programming language to learn first
What Java is
Using programs to boss your computer around
How programs work
How program errors (called bugs) are fixed
Acquiring a Java development tool
Getting ready to write programs
Choosing a Language
As you might have surmised at this point, computer programming is not as hard as it's cracked up to be. If you're comfortable enough with a computer to create a nice-looking resume, balance a checkbook with software such as Intuit Quicken, or create your own home page on the Web, you can write programs.
The key to learning how to program is to start with the right language. The programming language you choose often depends on the tasks you want the computer to accomplish. Each language has things it is well-suited for, as well as things that are difficultperhaps impossibleto do with the language. For example, many people use some form of the BASIC language when they are learning how to program because BASIC was created with beginners in mind.
The BASIC language was invented in the 1960s to be easy for students and beginners to learn (the B in BASIC stands for Beginner's). The downside to using some form of BASIC is that it's easy to fall into some sloppy programming habits with the language. Those habits can make it much more difficult to write complex programs and improve them later.
Microsoft Visual Basic combines the ease of BASIC with some powerful features to aid in the design of Windows software. (VBScript, which is short for Visual Basic Script, offers the simplicity of BASIC for small programs that run in conjunction with World Wide Web pages.) Visual Basic has been used to write thousands of sophisticated programs for commercial, business, and personal use. However, Visual Basic programs can be slower than Windows programs written in other languages, such as Borland C++. This difference is especially noticeable in programs that use a lot of graphicsgames, screen savers, and the like.
This book covers the Java programming language, which was developed by Sun Microsystems. Though Java is more difficult to learn than a language such as Visual Basic, it is a good starting place for several reasons. One of the biggest advantages of learning Java is that you can use it on the World Wide Web. If you're an experienced Web surfer, you have seen numerous Java programs in action. They can be used to create animated graphics, present text in new ways, play games, and help in other interactive efforts.
Another important advantage is that Java requires an organized approach for getting programs to work. The language is very particular about the way programs must be written, and it balks if programmers do not follow all of its rules. When you start writing Java programs, you might not see the language's choosy behavior as an advantage. You'll write a program and have several errors to fix before the program is finished. Some of your fixes might not be correct, and they will have to be redone. If you don't structure a program correctly as you are writing it, errors will result. In the coming hours, you'll learn about these rules and the pitfalls to avoid. The positive side of this extra effort is that your programs will be more reliable, useful, and error-free.
Java was invented by Sun Microsystems developer James Gosling as a better way to create computer programs. Gosling was unhappy with the way that the C++ programming language was working on a project he was doing, so he created a new language that did the job better. It's a matter of contentious debate whether Java is superior to other programming languages, of course, but the amount of attention paid to the language today shows that it has a large number of adherents. Book publishers obviously dig itmore than 1,000 books have been published about the language since its introduction. (This is my tenth, and I will keep writing more of them until prohibited by municipal, state, or federal law.)
Regardless of whether Java is the best language, it definitely is a great language to learn today. There are numerous resources for Java programmers on the Web, Java job openings are offered in many cities, and the language has become a major part of the Internet's past, present, and future. You'll get a chance to try out Java during Hour 2, "Writing Your First Program."
Learning Java or any other programming language makes it much easier to learn subsequent languages. Many languages are similar to each other, so you won't be starting from scratch when you dive into a new one. For instance, many C++ programmers find it fairly easy to learn Java, because Java borrows a lot of its structure and ideas from C++. Many programmers are comfortable using several different languages and will learn new ones as needed.
C++ is mentioned several times in this hour, and you might be tripping over the term wondering what it means, and more importantly, how it's pronounced. C++ is pronounced C-Plus-Plus, and it's a programming language that was developed by Bjarne Stroustrop and others at Bell Laboratories. C++ is an enhancement of the C programming language, hence the Plus-Plus part of the name. Why not just C+, then? The Plus-Plus part is a computer programming joke you'll understand later on.