Java 2 For Dummies

( 2 )

Overview

  • This updated bestseller covers programming essentials for the newest version of Java, the popular platform-independent, object-oriented programming language
  • The material is fully updated and focuses on the new Java SDK 1.5, addressing the needs of new or inexperienced Java developers
  • The fun and easy writing style walks readers through Java syntax basics and helps them write...
See more details below
Available through our Marketplace sellers.
Other sellers (Paperback)
  • All (23) from $1.99   
  • New (4) from $5.01   
  • Used (19) from $1.99   
Close
Sort by
Page 1 of 1
Showing All
Note: Marketplace items are not eligible for any BN.com coupons and promotions
$5.01
Seller since 2007

Feedback rating:

(999)

Condition:

New — never opened or used in original packaging.

Like New — packaging may have been opened. A "Like New" item is suitable to give as a gift.

Very Good — may have minor signs of wear on packaging but item works perfectly and has no damage.

Good — item is in good condition but packaging may have signs of shelf wear/aging or torn packaging. All specific defects should be noted in the Comments section associated with each item.

Acceptable — item is in working order but may show signs of wear such as scratches or torn packaging. All specific defects should be noted in the Comments section associated with each item.

Used — An item that has been opened and may show signs of wear. All specific defects should be noted in the Comments section associated with each item.

Refurbished — A used item that has been renewed or updated and verified to be in proper working condition. Not necessarily completed by the original manufacturer.

New
2001-10-15 Paperback New NEW, clean text, tight binding, nice cover.

Ships from: Rockford, IL

Usually ships in 1-2 business days

  • Canadian
  • International
  • Standard, 48 States
  • Standard (AK, HI)
  • Express, 48 States
  • Express (AK, HI)
$50.00
Seller since 2008

Feedback rating:

(169)

Condition: New
0764507656 BRAND NEW NEVER USED IN STOCK 125,000+ HAPPY CUSTOMERS SHIP EVERY DAY WITH FREE TRACKING NUMBER

Ships from: fallbrook, CA

Usually ships in 1-2 business days

  • Standard, 48 States
  • Standard (AK, HI)
$50.00
Seller since 2014

Feedback rating:

(164)

Condition: New
Brand new.

Ships from: acton, MA

Usually ships in 1-2 business days

  • Standard, 48 States
  • Standard (AK, HI)
$60.00
Seller since 2014

Feedback rating:

(164)

Condition: New
Brand new.

Ships from: acton, MA

Usually ships in 1-2 business days

  • Standard, 48 States
  • Standard (AK, HI)
Page 1 of 1
Showing All
Close
Sort by
Sending request ...

Overview

  • This updated bestseller covers programming essentials for the newest version of Java, the popular platform-independent, object-oriented programming language
  • The material is fully updated and focuses on the new Java SDK 1.5, addressing the needs of new or inexperienced Java developers
  • The fun and easy writing style walks readers through Java syntax basics and helps them write their first program
  • Shows readers how to create basic Java objects and figure out when they can reuse existing code
  • The new edition is also modified to better address the readers who may have some programming knowledge, but who are new to Java
Read More Show Less

Product Details

  • ISBN-13: 9780764507656
  • Publisher: Wiley, John & Sons, Incorporated
  • Publication date: 10/15/2001
  • Series: For Dummies Series
  • Edition description: Older Edition
  • Edition number: 1
  • Pages: 384
  • Product dimensions: 7.36 (w) x 9.16 (h) x 0.75 (d)

Meet the Author

Barry Burd is the author of Java 2 For Dummies, Beginning Programming with Java For Dummies, and Java & XML For Dummies, and a computer science professor at Drew University.
Read More Show Less

Table of Contents

Pt. I Getting started 9
Ch. 1 All about Java 11
Ch. 2 Running canned Java programs 23
Ch. 3 Using the basic building blocks 43
Pt. II Writing your own Java programs 69
Ch. 4 Making the most of variables and their values 71
Ch. 5 Controlling program flow with decision-making statements 99
Ch. 6 Controlling program flow with loops 121
Pt. III Working with the big picture : object-oriented programming 139
Ch. 7 Thinking in terms of classes and objects 141
Ch. 8 Saving time and money : reusing existing code 169
Ch. 9 Constructing new objects 199
Pt. IV Savvy Java techniques 219
Ch. 10 Putting variables and methods where they belong 221
Ch. 11 Using arrays and collections to juggle values 249
Ch. 12 Looking good when things take unexpected turns 279
Pt. V The part of tens 305
Ch. 13 Ten ways to avoid mistakes 307
Ch. 14 Ten sets of Web resources for Java 313
Pt. VI Appendixes 319
App When to use words like "public" and "private" 331
Read More Show Less

First Chapter

Java 2 For Dummies


By Barry Burd

John Wiley & Sons

ISBN: 0-7645-6858-2


Chapter One

All about Java

In This Chapter

* What Java is

* Where Java came from

* Why Java is so cool

* How to orient yourself to object-oriented programming

Say what you want about computers. As far as I'm concerned, computers are good for just two simple reasons:

  •   When computers do work, they feel no resistance, no stress, no boredom, and no fatigue. Computers are our electronic slaves. I have my computer working 24/7 doing calculations for SETI@home - the search for extraterrestrial intelligence. Do I feel sorry for my computer because it's working so hard? Does the computer complain? Will the computer report me to the National Labor Relations Board? No.

I can make demands, give the computer its orders, and crack the whip. Do I (or should I) feel the least bit guilty? Not at all.

  •   Computers move ideas, not paper. Not long ago, when you wanted to send a message to someone, you hired a messenger. The messenger got on his or her horse and delivered your message personally. The message was on paper, parchment, a clay tablet, or whatever physical medium was available at the time.

This whole process seems wasteful now, but that's only because you and I are sitting comfortably at the dawn of the electronic age. The thing is that messages are ideas. Physical things like ink, paper, and horses have little or nothing to do with real ideas. These physical things are just temporary carriers for ideas (temporary because people used them to carry ideas for several centuries). But, in truth, the ideas themselves are paperless, horseless, and messengerless.

So the neat thing about computers is that they carry ideas efficiently. They carry nothing but the ideas, a couple of photons, and a little electrical power. They do this with no muss, no fuss, and no extra physical baggage.

When you start dealing efficiently with ideas, something very nice happens. Suddenly, all the overhead is gone. Instead of pushing paper and trees, you're pushing numbers and concepts. Without the overhead, you can do things much faster and do things that are far more complex than ever before.

What You Can Do with Java

It would be so nice if all this complexity was free, but unfortunately, it isn't. Someone has to think hard and decide exactly what the computer will be asked to do. After that thinking is done, someone has to write a set of instructions for the computer to follow.

Given the current state of affairs, you can't write these instructions in English or any other language that people speak. Science fiction is filled with stories about people who say simple things to robots and get back disastrous, unexpected results. English and other such languages are unsuitable for communication with computers for several reasons:

  •   An English sentence can be misinterpreted. "Chew one tablet three times a day until finished."
  •   It's difficult to weave a very complicated command in English. "Join flange A to protuberance B, making sure to connect only the outermost lip of flange A to the larger end of the protuberance B, while joining the middle and inner lips of flange A to grommet C."
  •   An English sentence has lots of extra baggage. "Sentence has unneeded words."
  •   English is difficult to interpret. "As part of this Publishing Agreement between John Wiley & Sons, Inc. ('Wiley') and the Author ('Barry Burd'), Wiley shall pay the sum of one-thousand-two-hundred-fifty-seven dollars and sixty-three cents ($1,257.63) to the Author for partial submittal of Java 2 For Dummies, 2nd Edition ('the Work')."

To tell a computer what to do, you have to speak a special language and write terse, unambiguous instructions in that language. A special language of this kind is called a computer programming language. A set of instructions, written in such a language, is called a program. When they're looked at as a big blob, these instructions are called software or code. Here's what code looks like when it's written in Java:

import static java.lang.System.out;

class PayBarry { public static void main(String args) { double checkAmount = 1257.63; out.print("Pay to the order of"); out.print("Dr. Barry Burd"); out.print("$"); out.println(checkAmount); } }

Why You Should Use Java

It's time to celebrate! You've just picked up a copy of Java 2 For Dummies, 2nd Edition, and you're reading Chapter 1. At this rate, you'll be an expert Java programmer in no time at all, so rejoice in your eventual success by throwing a big party.

To prepare for the party, I'll bake a cake. I'm lazy, so I'll use a ready-to-bake cake mix. Let me see ... add water to the mix, and then add butter and eggs ... Hey, wait! I just looked at the list of ingredients. What's MSG? And what about propylene glycol? That's used in antifreeze, isn't it?

I'll change plans and make the cake from scratch. Sure, it's a little harder. But that way, I get exactly what I want.

Computer programs work the same way. You can use somebody else's program or write your own. If you use somebody else's program, you use whatever you get. When you write your own program, you can tailor the program especially for your needs.

Writing computer code is a big, worldwide industry. Companies do it, freelance professionals do it, hobbyists do it, all kinds of people do it. A typical big company has teams, departments, and divisions that write programs for the company. But you can write programs for yourself or someone else, for a living or for fun. In a recent estimate, the number of lines of code written each day by programmers in the United States alone exceeds the number of methane molecules on the planet Jupiter. Take almost anything that can be done with a computer. With the right amount of time, you can write your own program to do it. (Of course, the "right amount of time" may be very long, but that's not the point. Many interesting and useful programs can be written in hours or even minutes.)

Getting Perspective: Where Java Fits In

Here's a brief history of modern computer programming:

  •   1954-1957: FORTRAN is developed.

FORTRAN was the first modern computer programming language. For scientific programming, FORTRAN is a real racehorse. Year after year, FORTRAN is a leading language among computer programmers throughout the world. A well-known computer scientist, Tony Hoare, once said, "I don't know what the language of the year 2000 will look like, but I know it will be called FORTRAN."

  •   1959: COBOL is created.

The letter B in COBOL stands for Business, and business is just what COBOL is all about. The language's primary feature is the processing of one record after another, one customer after another, or one employee after another.

Within a few years after its initial development, COBOL became the most widely used language for business data processing. Even today, COBOL represents a large part of the computer programming industry.

  •   1972: Dennis Ritchie at AT&T Bell Labs develops the C programming language.

The look and feel that you see in this book's examples come from the C programming language. Code written in C uses curly braces, if statements, for statements, and so on.

In terms of power, you can use C to solve the same problems that you can solve by using FORTRAN, Java, or any other modern programming language. (You can write a scientific calculator program in COBOL, but doing that sort of thing would feel really strange.) The difference between one programming language and another isn't power. The difference is ease and appropriateness of use. That's where the Java language excels.

  •   1986: Bjarne Stroustrup (again at AT&T Bell Labs) develops C++.

Unlike its C language ancestor, the language C++ supports objectoriented programming. This represents a huge step forward.

  •   May 23, 1995: Sun Microsystems releases its first official version of the Java programming language.

Java improves upon the concepts in C++. Unlike C++, Java is streamlined for use on the World Wide Web. Java's "Write Once, Run Anywhere" philosophy makes the language ideal for distributing code across the Internet.

In addition, Java is a great general-purpose programming language. With Java, you can write windowed applications, build and explore databases, control handheld devices, and more. Within five short years, the Java programming language had 2.5 million developers worldwide. (I know. I have a commemorative T-shirt to prove it.)

  •   November 2000: The College Board announces that, starting in the year 2003, the Computer Science Advanced Placement exams will be based on Java.

Wanna know what that snot-nosed kid living down the street is going to be learning in high school next year? You guessed it - Java.

  •   March 2003: SkillMarket (mshiltonj.com/sm) reports that the demand for Java programmers tops the demand for C++ programmers by 42 percent.

And there's more! The demand for Java programmers beats the combined demand for C++ and C# programmers by 10 percent. Java programmers are more employable than VB (Visual Basic) programmers by a whopping 111 percent.

Object-Oriented Programming (OOP)

It's three in the morning. I'm dreaming about the history course that I failed in high school. The teacher is yelling at me, "You have two days to study for the final exam, but you won't remember to study. You'll forget and feel guilty, guilty, guilty."

Suddenly, the phone rings. I'm awakened abruptly from my deep sleep. (Sure, I disliked dreaming about the history course, but I like being awakened even less.) At first, I drop the telephone on the floor. After fumbling to pick it up, I issue a grumpy, "Hello, who's this?" A voice answers, "I'm a reporter from The New York Times. I'm writing an article about Java and I need to know all about the programming language in five words or less. Can you explain it?"

My mind is too hazy. I can't think. So I say anything that comes to my mind, and then go back to sleep.

Come morning, I hardly remember the conversation with the reporter. In fact, I don't remember how I answered the question. Did I tell the reporter where he could put his article about Java?

I put on my robe and rush to the front of my house's driveway. As I pick up the morning paper, I glance at the front page and see the two-inch headline:

Burd Calls Java "A Great Object-Oriented Language"

Object-oriented languages

Java is object-oriented. What does that mean? Unlike languages such as FORTRAN, which focus on giving the computer imperative "Do this/Do that" commands, object-oriented languages focus on data. Of course, object-oriented programs still tell the computer what to do. You start, however, by organizing the data, and the commands come later.

Object-oriented languages are better than "Do this/Do that" languages because they organize data in a way that lets people do all kinds of things with it. To modify the data, you can build on what you already have, rather than scrap everything you've done and start over each time you need to do something new. Although computer programmers are generally smart people, they took awhile to figure this out. For the full history lesson, see the sidebar "The winding road from FORTRAN to Java" (but I won't make you feel guilty if you don't read it).

Objects and their classes

In an object-oriented language, you use objects and classes to organize your data.

Imagine that you're writing a computer program to keep track of the houses in a new real-estate development. The development (still under construction) is a condominium. The houses differ only slightly from one another. Each house has a distinctive siding color, an indoor paint color, a kitchen cabinet style, and so on. In your object-oriented computer program, each house is an object.

But objects aren't the whole story. Although the houses differ slightly from one another, all the houses share the same list of characteristics. For instance, each house has a characteristic known as siding color. Each house has another characteristic known as kitchen cabinet style. In your object-oriented program, you need a master list containing all the characteristics that a house object can possess. This master list of characteristics is called a class.

So there you have it. Object-oriented programming is misnamed. It should really be called "programming with classes and objects."

Now notice that I put the word classes first. How dare I do this! Well, maybe I'm not so crazy. Think again about a housing development that's under construction. Somewhere on the lot, in a rickety trailer parked on bare dirt, is a master list of characteristics known as a blueprint. An architect's blueprint is like an object-oriented programmer's class. A blueprint is a list of characteristics that each house will have. The blueprint says, "siding." The actual house object has gray siding. The blueprint says, "kitchen cabinet." The actual house object has Louis XIV kitchen cabinets.

The analogy doesn't end with lists of characteristics. Another important parallel exists between blueprints and classes. A year after you create the blueprint, you use it to build ten houses. It's the same with classes and objects. First, the programmer writes code to describe a class. Then when the program runs, the computer creates objects from the (blueprint) class.

So that's the real relationship between classes and objects. The programmer defines a class, and from the class definition, the computer makes individual objects.

What's so good about an object-oriented language?

Based on the previous section's story about home building, imagine that you have already written a computer program to keep track of the building instructions for houses in a new development. Then, the big boss decides on a modified plan - a plan in which half the houses have three bedrooms, and the other half have four.

Continues...


Excerpted from Java 2 For Dummies by Barry Burd Excerpted by permission.
All rights reserved. No part of this excerpt may be reproduced or reprinted without permission in writing from the publisher.
Excerpts are provided by Dial-A-Book Inc. solely for the personal use of visitors to this web site.

Read More Show Less

Customer Reviews

Average Rating 4.5
( 2 )
Rating Distribution

5 Star

(1)

4 Star

(1)

3 Star

(0)

2 Star

(0)

1 Star

(0)

Your Rating:

Your Name: Create a Pen Name or

Barnes & Noble.com Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & Noble.com that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & Noble.com does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at BN.com or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation

Reminder:

  • - By submitting a review, you grant to Barnes & Noble.com and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Noble.com Terms of Use.
  • - Barnes & Noble.com reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & Noble.com also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on BN.com. It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

 
Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously
Sort by: Showing all of 2 Customer Reviews
  • Anonymous

    Posted March 31, 2004

    The best JAVA tutorial around

    Most of the JAVA books confuse reference book and teaching text and do neither very well. This book is an excellent teaching text that is very clear. The accompanying CD has really good stuff. A winner!

    Was this review helpful? Yes  No   Report this review
  • Anonymous

    Posted August 23, 2002

    ONE OF THE BEST!...

    I really thought this book was just great! I gave it 4 stars though because it was confusing at some points. It's also very Funny! It takes you step throught staep, you understand like probably 80% of it and don't get the other 20%!!! But it's still the best Java book ever! I really recomend this book for ANYONE who wants to learn Java, or Java 2! It's great!

    Was this review helpful? Yes  No   Report this review
Sort by: Showing all of 2 Customer Reviews

If you find inappropriate content, please report it to Barnes & Noble
Why is this product inappropriate?
Comments (optional)