Thông tin tài liệu
Barry Burd, PhD
Author of Beginning Programming
with Java For Dummies
Learn to:
• Combine several smaller programs to
create a bigger program
• Work with new libraries, closure, parallel
frameworks, and other new features
• Create basic Java objects and
reuse code
• Handle exceptions and events
Java
®
5th Edition
Making Everything Easier!
™
Visit the companion website at www.dummies.com/go/
javafordummies5e for lots of code samples that you can
use in your Java programs
Open the book and find:
• Definitions of the many terms
you’ll encounter
• The grammar of Java
• How to save time by reusing code
• All about if, for, switch, and
while statements
• An overview of object-oriented
programming
• Hints about handling exceptions
• How to write Java applets
• Ten ways to avoid mistakes
Barry Burd, PhD, is a professor of mathematics and computer science at
Drew University. He frequently contributes to various online technology
resources, including JavaBoutique.com, and is the author of Ruby On Rails
For Dummies and the previous edition of this book.
$29.99 US / $35.99 CN / £21.99 UK
ISBN 978-0-470-37173-2
Programming Languages/Java
Go to Dummies.com
®
for videos, step-by-step examples,
how-to articles, or to shop!
Jumpin’ Java! The bestselling
Java beginner’s book is now
fully updated for Java 7!
Java, the object-oriented programming language that works
on almost any computer, is what powers many of those cool
multimedia applications. Thousands have learned Java
programming from previous editions of this book — now
it’s your turn! Whether you’re new to programming or already
know a little Visual Basic or C++, you’ll be doing Java in a jiffy.
• The Java scoop — get an overview of Java, the enhancements in
Java 7, and the software tools you need
• Building blocks — learn to work with Java classes and methods
and add comments
• Get loopy — understand the value of variables and learn to control
program flow with loops or decision-making statements
• Class it up — explore classes and objects, constructors, and
subclasses, and see how to reuse your code
• A click ahead — experiment with variables and methods, use
arrays and collections to juggle values, and create programs
that respond to mouse clicks
Java
®
Burd
5th Edition
www.it-ebooks.info
Start with FREE Cheat Sheets
Cheat Sheets include
• Checklists
• Charts
• Common Instructions
• And Other Good Stuff!
Get Smart at Dummies.com
Dummies.com makes your life easier with 1,000s
of answers on everything from removing wallpaper
to using the latest version of Windows.
Check out our
• Videos
• Illustrated Articles
• Step-by-Step Instructions
Plus, each month you can win valuable prizes by entering
our Dummies.com sweepstakes. *
Want a weekly dose of Dummies? Sign up for Newsletters on
• Digital Photography
• Microsoft Windows & Office
• Personal Finance & Investing
• Health & Wellness
• Computing, iPods & Cell Phones
• eBay
• Internet
• Food, Home & Garden
Find out “HOW” at Dummies.com
*Sweepstakes not currently available in all countries; visit Dummies.com for official rules.
Get More and Do More at Dummies.com
®
To access the Cheat Sheet created specifically for this book, go to
www.dummies.com/cheatsheet/java
Mobile Apps
There’s a Dummies App for This and That
With more than 200 million books in print and over 1,600 unique
titles, Dummies is a global leader in how-to information. Now
you can get the same great Dummies information in an App. With
topics such as Wine, Spanish, Digital Photography, Certification,
and more, you’ll have instant access to the topics you need to
know in a format you can trust.
To get information on all our Dummies apps, visit the following:
www.Dummies.com/go/mobile from your computer.
www.Dummies.com/go/iphone/apps from your phone.
www.it-ebooks.info
Java
®
FOR
DUMmIES
‰
5TH EDITION
01_9780470371732-ffirs.indd i01_9780470371732-ffirs.indd i 7/6/11 6:57 PM7/6/11 6:57 PM
www.it-ebooks.info
01_9780470371732-ffirs.indd ii01_9780470371732-ffirs.indd ii 7/6/11 6:57 PM7/6/11 6:57 PM
www.it-ebooks.info
by Barry Burd
Java
®
FOR
DUMmIES
‰
5TH EDITION
01_9780470371732-ffirs.indd iii01_9780470371732-ffirs.indd iii 7/6/11 6:57 PM7/6/11 6:57 PM
www.it-ebooks.info
Java
®
For Dummies
®
, 5th Edition
Published by
Wiley Publishing, Inc.
111 River Street
Hoboken, NJ 07030-5774
www.wiley.com
Copyright © 2011 by Wiley Publishing, Inc., Indianapolis, Indiana
Published by Wiley Publishing, Inc., Indianapolis, Indiana
Published simultaneously in Canada
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or
by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permit-
ted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written
permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the
Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600.
Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley
& Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at http://
www.wiley.com/go/permissions.
Trademarks: Wiley, the Wiley Publishing logo, For Dummies, the Dummies Man logo, A Reference for the
Rest of Us!, The Dummies Way, Dummies Daily, The Fun and Easy Way, Dummies.com, Making Everything
Easier,
and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or
its af liates in the United States and other countries, and may not be used without written permission. Java
is a registered trademark of Oracle America, Inc. All other trademarks are the property of their respective
owners. Wiley Publishing, Inc., is not associated with any product or vendor mentioned in this book.
LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THE AUTHOR MAKE NO
REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF
THE CONTENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITH-
OUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY BE
CREATED OR EXTENDED BY SALES OR PROMOTIONAL MATERIALS. THE ADVICE AND STRATEGIES
CONTAINED HEREIN MAY NOT BE SUITABLE FOR EVERY SITUATION. THIS WORK IS SOLD WITH THE
UNDERSTANDING THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING LEGAL, ACCOUNTING, OR
OTHER PROFESSIONAL SERVICES. IF PROFESSIONAL ASSISTANCE IS REQUIRED, THE SERVICES OF
A COMPETENT PROFESSIONAL PERSON SHOULD BE SOUGHT. NEITHER THE PUBLISHER NOR THE
AUTHOR SHALL BE LIABLE FOR DAMAGES ARISING HEREFROM. THE FACT THAT AN ORGANIZATION
OR WEBSITE IS REFERRED TO IN THIS WORK AS A CITATION AND/OR A POTENTIAL SOURCE OF FUR-
THER INFORMATION DOES NOT MEAN THAT THE AUTHOR OR THE PUBLISHER ENDORSES THE INFOR-
MATION THE ORGANIZATION OR WEBSITE MAY PROVIDE OR RECOMMENDATIONS IT MAY MAKE.
FURTHER, READERS SHOULD BE AWARE THAT INTERNET WEBSITES LISTED IN THIS WORK MAY HAVE
CHANGED OR DISAPPEARED BETWEEN WHEN THIS WORK WAS WRITTEN AND WHEN IT IS READ.
For general information on our other products and services, please contact our Customer Care
Department within the U.S. at 877-762-2974, outside the U.S. at 317-572-3993, or fax 317-572-4002.
For technical support, please visit www.wiley.com/techsupport.
Wiley also publishes its books in a variety of electronic formats and by print-on-demand. Not all content
that is available in standard print versions of this book may appear or be packaged in all book formats.
If you have purchased a version of this book that did not include media that is referenced by or accom-
panies a standard print version, you may request this media by visiting http://booksupport.wiley.
com. For more information about Wiley products, visit us www.wiley.com.
Library of Congress Control Number: 2011932274
ISBN: 978-0-470-37173-2 (pbk); ISBN: 978-1-118-12830-5 (ebk); ISBN: 978-1-118-12831-2 (ebk);
ISBN: 978-1-118-12832-9 (ebk)
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
01_9780470371732-ffirs.indd iv01_9780470371732-ffirs.indd iv 7/6/11 6:57 PM7/6/11 6:57 PM
www.it-ebooks.info
About the Author
Barry Burd received an M.S. degree in Computer Science at Rutgers University
and a Ph.D. in Mathematics at the University of Illinois. As a teaching assistant
in Champaign-Urbana, Illinois, he was elected ve times to the university-wide
List of Teachers Ranked as Excellent by their Students.
Since 1980, Dr. Burd has been a professor in the Department of Mathematics
and Computer Science at Drew University in Madison, New Jersey. When he’s
not lecturing at Drew University, Dr. Burd leads training courses for profes-
sional programmers in business and industry. He has lectured at conferences
in the United States, Europe, Australia, and Asia. He is the author of several
articles and books, including Android Application Development All-in-One For
Dummies and Beginning Programming with Java For Dummies, both from Wiley
Publishing, Inc.
Dr. Burd lives in Madison, New Jersey, with his wife and two children. In his
spare time, he enjoys being a workaholic.
01_9780470371732-ffirs.indd v01_9780470371732-ffirs.indd v 7/6/11 6:57 PM7/6/11 6:57 PM
www.it-ebooks.info
01_9780470371732-ffirs.indd vi01_9780470371732-ffirs.indd vi 7/6/11 6:57 PM7/6/11 6:57 PM
www.it-ebooks.info
Dedication
for
Jennie, Sam, and Harriet,
Jennie and Benjamin, Katie and Abram,
and Basheva
01_9780470371732-ffirs.indd vii01_9780470371732-ffirs.indd vii 7/6/11 6:57 PM7/6/11 6:57 PM
www.it-ebooks.info
01_9780470371732-ffirs.indd viii01_9780470371732-ffirs.indd viii 7/6/11 6:57 PM7/6/11 6:57 PM
www.it-ebooks.info
[...]... I created just for comments and questions about this book, is JavaForDummies@allmy code.com And don’t forget — for the latest updates, visit this book’s website The sites’ main address is www.allmycode.com/JavaForDummies, but you can also get there by visiting www .dummies. com/go/javafordummies5e www.it-ebooks.info 03_9780470371732-intro.indd 7 7/6/11 6:57 PM 8 Java For Dummies, 5th Edition www.it-ebooks.info... PM 2 Java For Dummies, 5th Edition Conventions Used in This Book Almost every technical book starts with a little typeface legend, and Java For Dummies, 5th 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:... Java Find Its Files 379 Chapter 18: Ten Websites for Java 381 This Book’s Website 381 The Horse’s Mouth 381 Finding News, Reviews, and Sample Code 382 Looking for Java Jobs 382 Everyone’s Favorite Sites 382 Index 383 www.it-ebooks.info 02_9780470371732-ftoc.indd xix 7/6/11 6:57 PM xx Java For Dummies, 5th Edition. .. 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 www.it-ebooks.info 03_9780470371732-intro.indd 5 7/6/11 6:57 PM 6 Java For Dummies, 5th Edition Icons Used in This Book If you could watch me write this book, you’d... 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, 6th Edition. .. What is a Java virtual machine? 28 Developing Software 33 What is an Integrated Development Environment? 35 www.it-ebooks.info 02_9780470371732-ftoc.indd xiii 7/6/11 6:57 PM xiv Java For Dummies, 5th Edition Chapter 3: Using the Basic Building Blocks 39 Speaking the Java Language 39 The grammar and the common names 40 The words in a Java program... ava 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, softcover book, sit down, relax, and start reading Java For Dummies, 5th Edition How to Use This Book I wish... number of command line arguments 271 www.it-ebooks.info 02_9780470371732-ftoc.indd xvii 7/6/11 6:57 PM xviii Java For Dummies, 5th Edition Using Java Collections 272 Collection classes to the rescue 273 Using an ArrayList 274 Using generics (hot stuff!) 277 Testing for the presence of more data 278 Chapter 12: Looking Good When Things Take Unexpected Turns 281... any of those books that explain object-oriented programming in vague, general terms? I’m very proud to say that Java For Dummies, 5th Edition, isn’t like that In this book, I illustrate each concept with a simpleyet-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... ecome acquainted with Java Find out what Java is all about and whether you do (or don’t) want to use Java If you’ve heard things about Java and aren’t sure what they mean, the material in this part can help you If you’re staring at your computer, wondering how you’re going to get a Java program running, this part has the information that you need Maybe you’ve told people that you’re a Java expert, and now . Publishing logo, For Dummies, the Dummies Man logo, A Reference for the
Rest of Us!, The Dummies Way, Dummies Daily, The Fun and Easy Way, Dummies. com, Making. Burd
Java
®
FOR
DUMmIES
‰
5TH EDITION
01_9780470371732-ffirs.indd iii01_9780470371732-ffirs.indd iii 7/6/11 6:57 PM7/6/11 6:57 PM
www.it-ebooks.info
Java
®
Ngày đăng: 14/03/2014, 10:20
Xem thêm: Java for dummies 5th edition pot, Java for dummies 5th edition pot