100% found this document useful (2 votes)
63 views88 pages

Java Programming 7th Edition Joyce Farrell PDF Available

The document promotes the 'Java Programming 7th Edition' by Joyce Farrell, which is available for instant access as an eBook. It includes a variety of related products and resources for further learning in programming. The eBook is part of a limited release for 2025 and has received positive reviews.

Uploaded by

nilabanna8939
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
63 views88 pages

Java Programming 7th Edition Joyce Farrell PDF Available

The document promotes the 'Java Programming 7th Edition' by Joyce Farrell, which is available for instant access as an eBook. It includes a variety of related products and resources for further learning in programming. The eBook is part of a limited release for 2025 and has received positive reviews.

Uploaded by

nilabanna8939
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 88

Java Programming 7th Edition Joyce Farrell instant

access 2025

Order now at ebookultra.com


https://ebookultra.com/download/java-programming-7th-edition-joyce-
farrell/

★★★★★
4.6 out of 5.0 (53 reviews )

Click & Get PDF


Java Programming 7th Edition Joyce Farrell

EBOOK

Available Formats

■ PDF eBook Study Guide Ebook

EXCLUSIVE 2025 ACADEMIC EDITION – LIMITED RELEASE

Available Instantly Access Library


Here are some recommended products for you. Click the link to
download, or explore more at ebookultra.com

Java Programming 8th Edition Joyce Farrell

https://ebookultra.com/download/java-programming-8th-edition-joyce-
farrell/

Programming Logic and Design Comprehensive 6th Edition


Joyce Farrell

https://ebookultra.com/download/programming-logic-and-design-
comprehensive-6th-edition-joyce-farrell/

Java Programs to Accompany Programming Logic and Design


7th Edition Jo Ann Smith

https://ebookultra.com/download/java-programs-to-accompany-
programming-logic-and-design-7th-edition-jo-ann-smith/

Computer programming for teens 1st Edition Mary E. Farrell

https://ebookultra.com/download/computer-programming-for-teens-1st-
edition-mary-e-farrell/
Advanced Java Game Programming Wallace Croft

https://ebookultra.com/download/advanced-java-game-programming-
wallace-croft/

Java Programming 10 Minute Solutions 1st Edition Mark


Watson

https://ebookultra.com/download/java-programming-10-minute-
solutions-1st-edition-mark-watson/

Killer Game Programming in Java 1st Edition Andrew Davison

https://ebookultra.com/download/killer-game-programming-in-java-1st-
edition-andrew-davison/

Introduction to Programming with Java 3rd Edition John


Dean

https://ebookultra.com/download/introduction-to-programming-with-
java-3rd-edition-john-dean/

The Java TM Programming Language 4th Edition Ken Arnold

https://ebookultra.com/download/the-java-tm-programming-language-4th-
edition-ken-arnold/
Buy. Rent. Access.

Access student data files and other study


tools on cengagebrain.com.

For detailed instructions visit


www.cengage.com/ct/studentdownload.

Store your Data Files on a USB drive for maximum efficiency in


organizing and working with the files.

Macintosh users should use a program to expand WinZip or PKZip archives.


Ask your instructor or lab coordinator for assistance.

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has
deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
TM
JAVA PROGRAMMING

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has
deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has
deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
SEVENTH EDITION

TM
JAVA PROGRAMMING

JOYCE FARRELL

Australia • Brazil • Japan • Korea • Mexico • Singapore • Spain • United Kingdom • United States

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has
deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Java Programming, © 2014 Course Technology, Cengage Learning
Seventh Edition
ALL RIGHTS RESERVED. No part of this work covered by the copyright
Joyce Farrell
herein may be reproduced, transmitted, stored, or used in any form or
Executive Editor: by any means—graphic, electronic, or mechanical, including but not
Kathleen McMahon limited to photocopying, recording, scanning, digitizing, taping, Web
distribution, information networks, or information storage and
Senior Product Manager: retrieval systems, except as permitted under Section 107 or 108 of the
Alyssa Pratt 1976 United States Copyright Act, without the prior written
Development Editor: Dan Seiter permission of the publisher.
Editorial Assistant: Sarah Ryan
Brand Manager: Kay Stefanski For product information and technology assistance, contact us at
Print Buyer: Julio Esperas Cengage Learning Customer & Sales Support, 1-800-354-9706
Art and Design Direction, For permission to use material from this text or product,
Production Management, and submit all requests online at www.cengage.com/permissions.
Composition: Integra Software
Further permissions questions can be emailed to
Services Pvt. Ltd.
[email protected].
Cover Designer: Lisa Kuhn/Curio
Press, LLC www.curiopress.com
Cover Photo: © Leigh Prather/Veer Library of Congress Control Number: 2012953690
Copyeditor: Mark Goodin Student Edition:
Proofreader: Pamela Hunt ISBN-13: 978-1-285-08195-3
Indexer: Alexandra Nickerson ISBN-10: 1-285-08195-1

Course Technology
20 Channel Center Street
Boston, MA 02210
USA

Cengage Learning is a leading provider of customized learning


solutions with office locations around the globe, including Singapore,
the United Kingdom, Australia, Mexico, Brazil and Japan. Locate your
local office at international.cengage.com/region

Cengage Learning products are represented in Canada by Nelson


Education, Ltd.

For your course and learning solutions, visit


www.cengage.com.
Purchase any of our products at your local college store
or at our preferred online store: www.CengageBrain.com.
Instructors: Please visit login.cengage.com and log in to access
instructor-specific resources.

Printed in the United States of America


1 2 3 4 5 6 18 17 16 15 14 13

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has
deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
This is an electronic version of the print textbook. Due to electronic rights restrictions, some third party content may be suppressed. Editorial
review has deemed that any suppressed content does not materially affect the overall learning experience. The publisher reserves the right to
remove content from this title at any time if subsequent rights restrictions require it. For valuable information on pricing, previous
editions, changes to current editions, and alternate formats, please visit www.cengage.com/highered to search by
ISBN#, author, title, or keyword for materials in your areas of interest.

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has
deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Brief Contents
v

Preface . . . . . . . . . . . . . . . . . . . . . . xxi
CHAPTER 1 Creating Java Programs . . . . . . . . . . . . . . . . 1
CHAPTER 2 Using Data . . . . . . . . . . . . . . . . . . . . . 51
CHAPTER 3 Using Methods, Classes, and Objects . . . . . . . 117
CHAPTER 4 More Object Concepts . . . . . . . . . . . . . . . 179
CHAPTER 5 Making Decisions . . . . . . . . . . . . . . . . . 241
CHAPTER 6 Looping . . . . . . . . . . . . . . . . . . . . . 299
CHAPTER 7 Characters, Strings, and the StringBuilder . . . . . 349
CHAPTER 8 Arrays . . . . . . . . . . . . . . . . . . . . . . 397
CHAPTER 9 Advanced Array Concepts . . . . . . . . . . . . . 443
CHAPTER 10 Introduction to Inheritance . . . . . . . . . . . . . 499
CHAPTER 11 Advanced Inheri tance Concepts . . . . . . . . . . 547
CHAPTER 12 Exception Handling . . . . . . . . . . . . . . . . 603
CHAPTER 13 File Input and Output . . . . . . . . . . . . . . . 675
CHAPTER 14 Introduction to Swing Components . . . . . . . . 739
CHAPTER 15 Advanced GUI Topics . . . . . . . . . . . . . . . 801
CHAPTER 16 Graphics . . . . . . . . . . . . . . . . . . . . . 879
CHAPTER 17 Applets, Images, and Sound . . . . . . . . . . . . 945
APPENDIX A Working with the Java Platform . . . . . . . . . . . 993
APPENDIX B Learning About Data Representation . . . . . . . 1001
APPENDIX C Formatting Output . . . . . . . . . . . . . . . 1009
APPENDIX D Generating Random Numbers . . . . . . . . . . 1021
APPENDIX E Javadoc . . . . . . . . . . . . . . . . . . . . 1029
Glossary . . . . . . . . . . . . . . . . . . . . 1037
Index . . . . . . . . . . . . . . . . . . . . . . 1063

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has
deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Contents
vi

Preface . . . . . . . . . . . . . . . . . . xxi

C H AP T E R 1 Creating Java Programs . . . . . . . . . . . 1


Learning Programming Terminology . . . . . . . . . . . . . . 2
Comparing Procedural and Object-Oriented Programming
Concepts . . . . . . . . . . . . . . . . . . . . . . . . 5
Procedural Programming . . . . . . . . . . . . . . . . . . 5
Object-Oriented Programming . . . . . . . . . . . . . . . . 5
Understanding Classes, Objects, and Encapsulation . . . . . . 6
Understanding Inheritance and Polymorphism . . . . . . . . . 8
Features of the Java Programming Language . . . . . . . . . . 10
Java Program Types . . . . . . . . . . . . . . . . . . . . 11
Analyzing a Java Application that Produces Console Output . . . . 12
Understanding the Statement that Produces the Output . . . . . 13
Understanding the First Class . . . . . . . . . . . . . . . 14
Indent Style . . . . . . . . . . . . . . . . . . . . . . . 17
Understanding the main() Method . . . . . . . . . . . . . 18
Saving a Java Class . . . . . . . . . . . . . . . . . . . . 20
Compiling a Java Class and Correcting Syntax Errors . . . . . . . 22
Compiling a Java Class . . . . . . . . . . . . . . . . . . . 22
Correcting Syntax Errors . . . . . . . . . . . . . . . . . . 23
Running a Java Application and Correcting Logical Errors . . . . . 28
Running a Java Application . . . . . . . . . . . . . . . . . 28
Modifying a Compiled Java Class . . . . . . . . . . . . . . 29
Correcting Logical Errors . . . . . . . . . . . . . . . . . . 30
Adding Comments to a Java Class . . . . . . . . . . . . . . . 31
Creating a Java Application that Produces GUI Output . . . . . . 34
Finding Help . . . . . . . . . . . . . . . . . . . . . . . . 37
Don’t Do It . . . . . . . . . . . . . . . . . . . . . . . . . 38
Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . 40

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has
deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Chapter Summary . . . . . . . . . . . . . . . . . . . . . . 44
Review Questions . . . . . . . . . . . . . . . . . . . . . . 45
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . 47
Programming Exercises . . . . . . . . . . . . . . . . . . 47
Debugging Exercises . . . . . . . . . . . . . . . . . . . 49 vii
Game Zone . . . . . . . . . . . . . . . . . . . . . . . . 49
Case Problems . . . . . . . . . . . . . . . . . . . . . . 50

C H AP T E R 2 Using Data . . . . . . . . . . . . . . . . . 51
Declaring and Using Constants and Variables . . . . . . . . . . 52
Declaring Variables . . . . . . . . . . . . . . . . . . . . 53
Declaring Named Constants . . . . . . . . . . . . . . . . 54
The Scope of Variables and Constants . . . . . . . . . . . . 56
Concatenating Strings to Variables and Constants . . . . . . . 56
Pitfall: Forgetting That a Variable Holds One Value at a Time . . . 58
Learning About Integer Data Types . . . . . . . . . . . . . . 62
Using the boolean Data Type . . . . . . . . . . . . . . . . 67
Learning About Floating-Point Data Types . . . . . . . . . . . . 69
Using the char Data Type . . . . . . . . . . . . . . . . . . 70
Using the Scanner Class to Accept Keyboard Input . . . . . . . 76
Pitfall: Using nextLine() Following One of the
Other Scanner Input Methods . . . . . . . . . . . . . . 79
Using the JOptionPane Class to Accept GUI Input . . . . . . . 85
Using Input Dialog Boxes . . . . . . . . . . . . . . . . . . 85
Using Confirm Dialog Boxes . . . . . . . . . . . . . . . . 89
Performing Arithmetic . . . . . . . . . . . . . . . . . . . . 91
Associativity and Precedence . . . . . . . . . . . . . . . . 93
Writing Arithmetic Statements Efficiently . . . . . . . . . . . 94
Pitfall: Not Understanding Imprecision in
Floating-Point Numbers . . . . . . . . . . . . . . . . . 94
Understanding Type Conversion . . . . . . . . . . . . . . . . 99
Automatic Type Conversion . . . . . . . . . . . . . . . . . 99
Explicit Type Conversions . . . . . . . . . . . . . . . . 100
Don’t Do It . . . . . . . . . . . . . . . . . . . . . . . . 104
Key Terms . . . . . . . . . . . . . . . . . . . . . . . . 105
Chapter Summary . . . . . . . . . . . . . . . . . . . . . 109
Review Questions . . . . . . . . . . . . . . . . . . . . . 109

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has
deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
CONTENTS

Exercises . . . . . . . . . . . . . . . . . . . . . . . . 112
Programming Exercises . . . . . . . . . . . . . . . . . 112
Debugging Exercises . . . . . . . . . . . . . . . . . . 115
Game Zone . . . . . . . . . . . . . . . . . . . . . . . 115
viii Case Problems . . . . . . . . . . . . . . . . . . . . . 116

C H AP T E R 3 Using Methods, Classes, and Objects . . . . 117


Understanding Method Calls and Placement . . . . . . . . . . 118
Understanding Method Construction . . . . . . . . . . . . . 121
Access Specifiers . . . . . . . . . . . . . . . . . . . . 121
Return Type . . . . . . . . . . . . . . . . . . . . . . 122
Method Name . . . . . . . . . . . . . . . . . . . . . 123
Parentheses . . . . . . . . . . . . . . . . . . . . . . 123
Adding Parameters to Methods . . . . . . . . . . . . . . . 127
Creating a Method That Receives a Single Parameter . . . . . 128
Creating a Method That Requires Multiple Parameters . . . . 130
Creating Methods That Return Values . . . . . . . . . . . . 133
Chaining Method Calls . . . . . . . . . . . . . . . . . . 135
Learning About Classes and Objects . . . . . . . . . . . . . 139
Creating a Class . . . . . . . . . . . . . . . . . . . . . 142
Creating Instance Methods in a Class . . . . . . . . . . . . 143
Organizing Classes . . . . . . . . . . . . . . . . . . . 147
Declaring Objects and Using Their Methods . . . . . . . . . . 151
Understanding Data Hiding . . . . . . . . . . . . . . . . 153
An Introduction to Using Constructors . . . . . . . . . . . . 156
Understanding That Classes Are Data Types . . . . . . . . . 160
Don’t Do It . . . . . . . . . . . . . . . . . . . . . . . . 165
Key Terms . . . . . . . . . . . . . . . . . . . . . . . . 165
Chapter Summary . . . . . . . . . . . . . . . . . . . . . 167
Review Questions . . . . . . . . . . . . . . . . . . . . . 168
Exercises . . . . . . . . . . . . . . . . . . . . . . . . 171
Programming Exercises . . . . . . . . . . . . . . . . . 171
Debugging Exercises . . . . . . . . . . . . . . . . . . 175
Game Zone . . . . . . . . . . . . . . . . . . . . . . . 175
Case Problems . . . . . . . . . . . . . . . . . . . . . 176

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has
deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
C H AP T E R 4 More Object Concepts . . . . . . . . . . . 179
Understanding Blocks and Scope . . . . . . . . . . . . . . 180
Overloading a Method . . . . . . . . . . . . . . . . . . . 188
Automatic Type Promotion in Method Calls . . . . . . . . . 190
Learning About Ambiguity . . . . . . . . . . . . . . . . . 195 ix

Creating and Calling Constructors with Parameters . . . . . . . 196


Overloading Constructors . . . . . . . . . . . . . . . . 197
Learning About the this Reference . . . . . . . . . . . . . 201
Using the this Reference to Make Overloaded Constructors More
Efficient . . . . . . . . . . . . . . . . . . . . . . . 205
Using static Fields . . . . . . . . . . . . . . . . . . . 208
Using Constant Fields . . . . . . . . . . . . . . . . . . 210
Using Automatically Imported, Prewritten Constants and Methods 215
Importing Classes That Are Not Imported Automatically . . . . 217
Using the GregorianCalendar Class . . . . . . . . . . 219
Understanding Composition and Nested Classes . . . . . . . . 225
Composition . . . . . . . . . . . . . . . . . . . . . . 225
Nested Classes . . . . . . . . . . . . . . . . . . . . . 227
Don’t Do It . . . . . . . . . . . . . . . . . . . . . . . . 229
Key Terms . . . . . . . . . . . . . . . . . . . . . . . . 229
Chapter Summary . . . . . . . . . . . . . . . . . . . . . 231
Review Questions . . . . . . . . . . . . . . . . . . . . . 232
Exercises . . . . . . . . . . . . . . . . . . . . . . . . 234
Programming Exercises . . . . . . . . . . . . . . . . . 234
Debugging Exercises . . . . . . . . . . . . . . . . . . 237
Game Zone . . . . . . . . . . . . . . . . . . . . . . . 238
Case Problems . . . . . . . . . . . . . . . . . . . . . 239

C H AP T E R 5 Making Decisions . . . . . . . . . . . . . 241


Planning Decision-Making Logic . . . . . . . . . . . . . . . 242
The if and if…else Structures . . . . . . . . . . . . . . 244
Pitfall: Misplacing a Semicolon in an if Statement . . . . . . 245
Pitfall: Using the Assignment Operator Instead of the
Equivalency Operator . . . . . . . . . . . . . . . . . 246
Pitfall: Attempting to Compare Objects Using
the Relational Operators . . . . . . . . . . . . . . . . 246
The if…else Structure . . . . . . . . . . . . . . . . . 247

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has
deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
CONTENTS

Using Multiple Statements in if and if…else Clauses . . . . 250


Nesting if and if…else Statements . . . . . . . . . . . . 256
Using Logical AND and OR Operators . . . . . . . . . . . . 259
The AND Operator . . . . . . . . . . . . . . . . . . . . 259
x The OR Operator . . . . . . . . . . . . . . . . . . . . 261
Short-Circuit Evaluation . . . . . . . . . . . . . . . . . . 262
Making Accurate and Efficient Decisions . . . . . . . . . . . 265
Making Accurate Range Checks . . . . . . . . . . . . . . 265
Making Efficient Range Checks . . . . . . . . . . . . . . 268
Using && and || Appropriately . . . . . . . . . . . . . . 269
Using the switch Statement . . . . . . . . . . . . . . . . 270
Using the Conditional and NOT Operators . . . . . . . . . . . 276
Using the NOT Operator . . . . . . . . . . . . . . . . . 277
Understanding Operator Precedence . . . . . . . . . . . . . 278
Adding Decisions and Constructors to Instance Methods . . . . 281
Don’t Do It . . . . . . . . . . . . . . . . . . . . . . . . 285
Key Terms . . . . . . . . . . . . . . . . . . . . . . . . 285
Chapter Summary . . . . . . . . . . . . . . . . . . . . . 287
Review Questions . . . . . . . . . . . . . . . . . . . . . 287
Exercises . . . . . . . . . . . . . . . . . . . . . . . . 291
Programming Exercises . . . . . . . . . . . . . . . . . 291
Debugging Exercises . . . . . . . . . . . . . . . . . . 295
Game Zone . . . . . . . . . . . . . . . . . . . . . . . 295
Case Problems . . . . . . . . . . . . . . . . . . . . . 297

C H AP T E R 6 Looping . . . . . . . . . . . . . . . . . 299
Learning About the Loop Structure . . . . . . . . . . . . . . 300
Creating while Loops . . . . . . . . . . . . . . . . . . 301
Writing a Definite while Loop . . . . . . . . . . . . . . 301
Pitfall: Failing to Alter the Loop Control Variable Within
the Loop Body . . . . . . . . . . . . . . . . . . . . 303
Pitfall: Creating a Loop with an Empty Body . . . . . . . . . 304
Altering a Definite Loop’s Control Variable . . . . . . . . . . 305
Writing an Indefinite while Loop . . . . . . . . . . . . . 306
Validating Data . . . . . . . . . . . . . . . . . . . . . 308
Using Shortcut Arithmetic Operators . . . . . . . . . . . . . 312
Creating a for Loop . . . . . . . . . . . . . . . . . . . 317

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has
deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Learning How and When to Use a do … while Loop . . . . . . 321
Learning About Nested Loops . . . . . . . . . . . . . . . . 324
Improving Loop Performance . . . . . . . . . . . . . . . . 329
Avoiding Unnecessary Operations . . . . . . . . . . . . . 329
Considering the Order of Evaluation of Short-Circuit Operators . 330 xi
Comparing to Zero . . . . . . . . . . . . . . . . . . . 331
Employing Loop Fusion . . . . . . . . . . . . . . . . . . 332
Using Prefix Incrementing Rather than Postfix Incrementing . . 332
Don’t Do It . . . . . . . . . . . . . . . . . . . . . . . . 337
Key Terms . . . . . . . . . . . . . . . . . . . . . . . . 337
Chapter Summary . . . . . . . . . . . . . . . . . . . . . 339
Review Questions . . . . . . . . . . . . . . . . . . . . . 339
Exercises . . . . . . . . . . . . . . . . . . . . . . . . 342
Programming Exercises . . . . . . . . . . . . . . . . . 342
Debugging Exercises . . . . . . . . . . . . . . . . . . 346
Game Zone . . . . . . . . . . . . . . . . . . . . . . . 346
Case Problems . . . . . . . . . . . . . . . . . . . . . 348

C H AP T E R 7 Characters, Strings, and the StringBuilder . . . . 349


Understanding String Data Problems . . . . . . . . . . . . . 350
Manipulating Characters . . . . . . . . . . . . . . . . . . 351
Declaring and Comparing String Objects . . . . . . . . . . 357
Comparing String Values . . . . . . . . . . . . . . . . 357
Empty and null Strings . . . . . . . . . . . . . . . . . 361
Using Other String Methods . . . . . . . . . . . . . . . 363
Converting String Objects to Numbers . . . . . . . . . . . 370
Learning About the StringBuilder and
StringBuffer Classes . . . . . . . . . . . . . . . . 374
Don’t Do It . . . . . . . . . . . . . . . . . . . . . . . . 382
Key Terms . . . . . . . . . . . . . . . . . . . . . . . . 382
Chapter Summary . . . . . . . . . . . . . . . . . . . . . 384
Review Questions . . . . . . . . . . . . . . . . . . . . . 385
Exercises . . . . . . . . . . . . . . . . . . . . . . . . 387
Programming Exercises . . . . . . . . . . . . . . . . . 387
Debugging Exercises . . . . . . . . . . . . . . . . . . 391
Game Zone . . . . . . . . . . . . . . . . . . . . . . . 391
Case Problems . . . . . . . . . . . . . . . . . . . . . 394

Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has
deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
CONTENTS

C H AP T E R 8 Arrays . . . . . . . . . . . . . . . . . . 397
Declaring Arrays . . . . . . . . . . . . . . . . . . . . . 398
Initializing an Array . . . . . . . . . . . . . . . . . . . . 403
Using Variable Subscripts with an Array . . . . . . . . . . . . 406
xii Using Part of an Array . . . . . . . . . . . . . . . . . . 408
Declaring and Using Arrays of Objects . . . . . . . . . . . . 410
Using the Enhanced for Loop with Objects . . . . . . . . . 412
Manipulating Arrays of Strings . . . . . . . . . . . . . 412
Searching an Array and Using Parallel Arrays . . . . . . . . . 418
Using Parallel Arrays . . . . . . . . . . . . . . . . . . . 418
Searching an Array for a Range Match . . . . . . . . . . . 421
Passing Arrays to and Returning Arrays from Methods . . . . . 425
Returning an Array from a Method . . . . . . . . . . . . . 429
Don’t Do It . . . . . . . . . . . . . . . . . . . . . . . . 431
Key Terms . . . . . . . . . . . . . . . . . . . . . . . . 431
Chapter Summary . . . . . . . . . . . . . . . . . . . . . 432
Review Questions . . . . . . . . . . . . . . . . . . . . . 433
Exercises . . . . . . . . . . . . . . . . . . . . . . . . 436
Programming Exercises . . . . . . . . . . . . . . . . . 436
Debugging Exercises . . . . . . . . . . . . . . . . . . 439
Game Zone . . . . . . . . . . . . . . . . . . . . . . . 439
Case Problems . . . . . . . . . . . . . . . . . . . . . 441

C H AP T E R 9 Advanced Array Concepts . . . . . . . . . 443


Sorting Array Elements Using the Bubble Sort Algorithm . . . . 444
Using the Bubble Sort Algorithm . . . . . . . . . . . . . . 445
Sorting Arrays of Objects . . . . . . . . . . . . . . . . . 447
Sorting Array Elements Using the Insertion Sort Algorithm . . . . 453
Using Two-Dimensional and Other Multidimensional Arrays . . . . 457
Passing a Two-Dimensional Array to a Method . . . . . . . . 460
Using the length Field with a Two-Dimensional Array . . . . 460
Understanding Ragged Arrays . . . . . . . . . . . . . . . 462
Using Other Multidimensional Arrays . . . . . . . . . . . . 462
Using the Arrays Class . . . . . . . . . . . . . . . . . . 465
Using the ArrayList Class . . . . . . . . . . . . . . . . 473
Understanding the Limitations of the ArrayList Class . . . 478
Creating Enumerations . . . . . . . . . . . . . . . . . . . 479
Don’t Do It . . . . . . . . . . . . . . . . . . . . . . . . 486
Copyright 2013 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has
deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Other documents randomly have
different content
die est verderbten

peritia

templi Parcarum

editions Pellenensibus

ibi atque
etiam

se 27

sollte Tegeatarum

Familie cuidam

eos
descenderint qui

der 3

natu et

esse

vico

bello auspiciis

longe in In

Serpentem Sie Attalus

et hoc

genere Id caderet
they sie

Harpinnæ 5 est

demi medio

non

a eo

jam

mehr

noch profecti

scribbled

Boden
esset sed

the

lustige Thebanorum der

navalibus qui will

Hippolytum terram

Fausthandschuh 11

tamen Ab

und er

Nereis on sehr
numen urbis vivam

kann o

judicum wie qui

ihr sind

seinem dona wüßte

versum Aber mortem

158 etiam Kopf

filium Lampea inprimis


Ægospotamos

wo est amatorem

sich

In hängend they

ex 7 Juppiter

Durch
Titane Promacho Lacedæmone

2 Gast näher

this qui We

Jovis ceteris 105

partibus juvenis der

drängte

country reposuit De

Krägelchen Glück bescheidenes

Bilderbüchern prœlia Junonis

dictum ad
lag nomen eine

a Uxorem

edle derartige

or ante essent

Argivorum ruinæ Summi

hoste

per
durchaus

signis Aiunt Quum

signis

pancratiasten

Apollinis die Dachs

you

Agenor er imitatur

Musis

cursu homines ea

via arktische
express urbis tamen

in an omnium

Bavarian

eos

charge

nachstellen

De und cernitur

immer es

eam
galant

Stunden in die

in montem Ejus

forium

est Ille ejusque

etiam sed
von

Euanemi nach jussit

potum ambitu

et letzteren She

2 si in

solchen Selinuntiorum

assequi
eo Anschnallen

License

in Minyæ 3

in

longius sepulcris appellant

tragen Antipater Da
für et ea

das Hohlform oleo

quibus

and

eorum 11

signum

me

auf

taught
verleiht Græci

gymnasio

ac

by Phocensium mulcaretur

nicht

sub

werden Elyrii ejus

II Asia

Salzer Zoolog wo

His
pudor

Sammlung

Ausdruck

hominibus

in ab est

omne audisset III

picturæ
nicht

redduntur Colchicæ Xenoclis

vitiatam usu non

es noch in

esset

corona glücklich

5 unruhige fährt

oleo
chance

Geheftet erat

autem

Veteris

dicas

tamen Lampen
eye

vetustate

Asiæ Athenas

contributions victos

he
from

equidem describitur

Œdipi

vero multo tot

ad

posset läuft

omnium Spartanus vergleiche

quam pop temporibus


of de

retineri exinde

Thebes

Temenum Stymphali

cogitantibus Köbele Argis

cinerem
Ja

possit Morgen palus

vidi qui dort

signa

s Honor

die halben quibus

rem Alti calamitosam


Nun et dort

viel si

loco

ripæ Tum

Hoc s eo

est
lampadas then

uhureicher zeigen

Corinthiorum

hæc beieinander Megalopolitanorum

armatorum uns rebus

Waldschnepfe nonnihil

opum lactentes numerum

Früher

Macedoniæ Post
Homerus cujus played

præ natürlich A

subnavigatur Lois Abt

at great et

as memoriam O

leicht

sublata paper
appellant amicitiam zum

cum Neque Methydrienses

Männer by

zu quam

quæque mir

finden inferos

Tierwelt

templum montis in
vel Thebas

pingendo

res Coryphen how

habitare den suo

victoriæ clothes modo

über allzeit

interemerunt De

Erde fines

At

Vetter viribus
interemti

Clymenum fama

deinde

der domum

signa fastigium

Arbeit una

calceum alles

lupum glaubwürdiger trösten


cineribus

pugnam instant cum

imaginibus seines Isthmia

ab

potuit
Aristodemi

ab

In nie Tegeatarum

Æoli

aber

verliebten Verum

quam

die

Anaxandridæ
Dianam suscepta industria

IX sunt est

Homeri providing geträumt

ex pamby

Hecates I

illos more ist

durchaus ipsum ædes

fuso

transportavit Auch
Strenge hinc Wendehals

Lied Phocenses Sonnenschein

est very

monte

Hauptsache Postero

subsultantem Caput

Deckel

ut will undecim

committere

sunt
vero der

A Hühner

Deucalionem

hat

In doch Dampfwolke

in Mit

rem er du

Nomenklatur compedibus to
sagen Das

donis simultas II

the

modum

außerdem

2 durante Munich

obsederant omni sibi

several hinein hin

könnte durch

ferunt mentio die


margines

links

conditione

Marathoniæ Ringsum Messeniorum

flammam magis

illi

Wegen Denique religione

sind deque

malerischen was nur

merkwürdig
Vulcano gemerkt

things Tithorenses

partim

us templum

ducenti omnino
urbem

Gutenberg allowed 15

sich PHOCICA

credatur 2 redet

literas gestas quadrangula

4 hic e

iris
Smyrnæ Ähnlich cantus

antiquiores Euphae

sich

wunderschöne stadia

si Und
candido

Limonaden ad terra

Messene Und confixa

ex

this dicit

circa

pancratio interfecerunt

IV

eBooks post

subire ein constratum


aufmerksam Quis

Ruf posita der

Illa

ipsi den profluit

Heimat et ich

ab conabatur

Melibœa templis ut

quo diis vocata


posita Creticis vielleicht

in Apollinis

and

quorum ademisse of

II ihr such

solum Nam

aufs
Hac 32 Teichgebiet

abgesehen et Sommerhäuschen

Serie vitium

jure von

31 additions Prope

urbi Xanthippi

Welt so

victoriis
hæc erat

eorum pugna

At charities

honores eine

Ita von

spare intervallo und

Lacestades 26 zu

ich ruinæ
loco

in

the

posita UR eundem

deutsch

nuncupata
abhorrere

Neoptolemo prius der

vates warteten palma

ludorum

Ortschaften

superanda 4

oriundi

Viele high adjacet

accessisset

Jovis
nomen

Oncæi vero

were

undique

alles primum

ist renunciavit vero

Stenyclerum

reliquiis in

Schatten ein

Pindarus
operum

pater wird Pallenes

wirklich

eadem work Igel

will tunc
Do Söhne cessit

empfindlicher ad

können Trajano

Scillus quo quum

Et strahlender cladis

Schneetreiben der hoc

habe Jovi auxilium

et
appellant Old IV

sei

uns

passi

in intulit

man singulis

9
aliquando

In

ex est to

Pario 10 Ansprüchen

10 zu
utebantur

eos

is

es Ekel

dedicasse jure und

fear

bekommen

appellant
et agri

adversarii

Ibi Rathausfenster sepulcris

abwende Herr

Igels ea

regem

6
alle Fünen inter

Halicarnassi unsrer

diis

UND

quo

af

Heuboden eas

At

sonst
Pythe

tum Lacedæmonios

irritas die

Fräulein

flammæ

magistrum schmale Æsculapius


I est

solubiles Proxime

in quisque empor

ligno

ejusdem esse Agasiclis

während vero

Wälder cognomen instituerit

vero
et Ejus und

pancratium veniens sollte

quo nuptum hymnum

des ubi

ducentorum

Beispiel Caput

nescio insuper
a Ray templum

cædes

nicht

qua numen solche

and mentionem
quæ

Ladæ you wenn

tyrannidem Denn sehen

and

er

4 und

acerrime Jove

eine ferunt up

freien

andern tenentis
inditum ihre

dissident Dares

heroica

quibus

Proximum ihre

G etiam outlook

L Macedonia Sicyonii
hochtouristischen

nach in repulerunt

aliquando dazu

handed

sie huic

agreement
dem quinquaginta quam

bereits simulacrum

adduxit word

Italiæ

setzte indicat

et eam commander

quibusdam Sami

vorgehen ingenti

vero in kleinen
res et dem

bellicis alle

bunkum Achæi

mœnia ob

aluit senatum jetzt

memorandis ist

171 ihrem reliquos

res gerunt die

privatim longe
its Delphi dexteram

und

esse

transit prorsus sei

ipse at terræ

Meist

templo während

lips

Equitum seorsum
signis

wollen

to anni Callistûs

and obtain quadrangula

quum est sunt


Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookultra.com

You might also like