Sams Teach Yourself Java™ in 24 Hours (Covering Java 7 and Android)

(singke) #1
ptg

4 HOUR 1:Becoming a Programmer


The first hour of this book provides an introduction to programming fol-
lowed by instructions on how to set up your computer so you can write
Java programs.

Choosing a Language
If you’re comfortable enough with acomputer to prepare a nice-looking
résumé, balance a checkbook, or share your vacation photos on Facebook,
you can write computer 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
to accomplish. Each language has strengths and weaknesses. For many
years, people learned to program with some form of the BASIC language
because the language was created with beginners in mind.
Microsoft Visual Basichas been used to write thousands of sophisticated
programs for commercial, business, and personal use. However, programs
created with some versions of Visual Basic can be slower than programs
written in other languages such as C# and Visual C++. This difference is
especially noticeable in programs that use a lot of graphics, such as games.
This book covers the Java programming language, which is offered by
Oracle Corporation. Though Java is more difficult to learn than a language
such as Visual Basic, it’s a good starting place for several reasons. One
advantage of learning Java is that you can use it on the Web and mobile
phones. Java programs can be used to create Android phone apps, browser
games, and other hot areas of software development.
Another important advantage is that Java requires an organized approach
for getting programs to work. You must be particular about how you write
programs; Java balks when you don’t follow its rules.
When you start writing Java programs, you might not see the language’s
persnickety behavior as an advantage. You might tire of writing a program
and having several errors to fix before the program is finished.
In the coming hours, though, you learn about Java’s rules and the pitfalls
to avoid. The benefit of this extra effort is that the programs you create are
more reliable, useful, and error-free.
Java was invented by developer James Goslingas a better way to create
computer programs. While working at Sun Microsystems, Gosling was
unhappy with the way the C++ programming language was performing
on a project, so he created a new language that did the job better. It’s a

NOTE
The BASIC languagewas invent-
ed 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 sloppy
programming habits with the
language.

Free download pdf