100% found this document useful (2 votes)
21 views

(Ebook) Java(TM) Programming: From Problem Analysis to Program Design by D. S. Malik ISBN 9781111530532, 111153053X 2024 scribd download

The document provides information about various ebooks related to programming, particularly focusing on Java, C++, and C# by D. S. Malik and Barbara Doyle. It includes details such as ISBN numbers, download links, and a brief overview of the contents of the Java Programming textbook. The document emphasizes the availability of these resources for educational purposes and encourages exploration of more ebooks on the website.

Uploaded by

mprodrabeai
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
21 views

(Ebook) Java(TM) Programming: From Problem Analysis to Program Design by D. S. Malik ISBN 9781111530532, 111153053X 2024 scribd download

The document provides information about various ebooks related to programming, particularly focusing on Java, C++, and C# by D. S. Malik and Barbara Doyle. It includes details such as ISBN numbers, download links, and a brief overview of the contents of the Java Programming textbook. The document emphasizes the availability of these resources for educational purposes and encourages exploration of more ebooks on the website.

Uploaded by

mprodrabeai
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 81

Visit https://ebooknice.

com to download the full version and


explore more ebooks

(Ebook) Java(TM) Programming: From Problem Analysis


to Program Design by D. S. Malik ISBN 9781111530532,
111153053X

_____ Click the link below to download _____


https://ebooknice.com/product/java-tm-programming-from-
problem-analysis-to-program-design-2271130

Explore and download more ebooks at ebooknice.com


Here are some recommended products that might interest you.
You can download now and explore!

(Ebook) Java programming : from problem analysis to program design by


D S Malik ISBN 9781111530532, 9781111577643, 111153053X, 1111577641

https://ebooknice.com/product/java-programming-from-problem-analysis-
to-program-design-4130342

ebooknice.com

(Ebook) Java Programming: From Problem Analysis to Program Design, 4th


Edition by D. S. Malik ISBN 1439035660

https://ebooknice.com/product/java-programming-from-problem-analysis-
to-program-design-4th-edition-2365278

ebooknice.com

(Ebook) C++ Programming: From Problem Analysis to Program Design by D.


S. Malik ISBN 9781133626381, 1133626386

https://ebooknice.com/product/c-programming-from-problem-analysis-to-
program-design-4334672

ebooknice.com

(Ebook) C++ Programming: From Problem Analysis to Program Design by D.


S. Malik ISBN 9781337102087, 1337102083

https://ebooknice.com/product/c-programming-from-problem-analysis-to-
program-design-7031230

ebooknice.com
(Ebook) C++ programming : from problem analysis to program design by D
S Malik ISBN 9781423902096, 1423902092

https://ebooknice.com/product/c-programming-from-problem-analysis-to-
program-design-4700604

ebooknice.com

(Ebook) C++ Programming: From Problem Analysis to Program Design, 5th


by D. S. Malik ISBN 9780538798082, 0538798084

https://ebooknice.com/product/c-programming-from-problem-analysis-to-
program-design-5th-2336846

ebooknice.com

(Ebook) C# Programming: From Problem Analysis to Program Design by


Barbara Doyle ISBN 1423901460

https://ebooknice.com/product/c-programming-from-problem-analysis-to-
program-design-2444624

ebooknice.com

(Ebook) C# Programming: From Problem Analysis to Program Design by


Barbara Doyle ISBN 9781285096261, 1285096266

https://ebooknice.com/product/c-programming-from-problem-analysis-to-
program-design-4178294

ebooknice.com

(Ebook) C# Programming: From Problem Analysis to Program Design by


Barbara Doyle ISBN 9781285856872, 1285856872, 2015937761

https://ebooknice.com/product/c-programming-from-problem-analysis-to-
program-design-10810090

ebooknice.com
Java TM Programming From Problem Analysis to
Program Design 5th Edition D. S. Malik Digital Instant
Download
Author(s): D. S. Malik
ISBN(s): 9781111530532, 111153053X
Edition: 5
File Details: PDF, 3.43 MB
Year: 2011
Language: english
Licensed to: iChapters User
Licensed to: iChapters User

JAVA PROGRAMMING
FROM PROBLEM ANALYSIS TO PROGRAM DESIGN

FIFTH EDITION

D.S. MALIK

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

Copyright 2011 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.
Licensed to: iChapters User

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 2011 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.

!"#$%&$$&'(&)*+),,-*.*/00111** "2323$11133456475189
Licensed to: iChapters User

Java Programming: From Problem Analysis ª 2012 Course Technology, Cengage Learning
to Program Design, Fifth Edition
ALL RIGHTS RESERVED. No part of this work covered by the
D.S. Malik copyright herein may be reproduced, transmitted, stored or used
Executive Editor: Marie Lee in any form or by any means graphic, electronic, or mechanical,
including but not limited to photocopying, recording, scanning,
Acquisitions Editor: Brandi Shailer digitizing, taping, Web distribution, information networks, or
Senior Product Manager: Alyssa Pratt information storage and retrieval systems, except as permitted
Editorial Assistant: Jacqueline Lacaire under Section 107 or 108 of the 1976 United States Copyright Act,
without the prior written permission of the publisher.
Content Project Manager: Lisa Weidenfeld
Associate Marketing Manager: Shanna For product information and technology assistance, contact us at
Shelton Cengage Learning Customer & Sales Support, 1-800-354-9706
Art Director: Faith Brosnan For permission to use material from this text or product, submit
all requests online at www.cengage.com/permissions
Proofreader: Andrea Schein
Further permissions questions can be emailed to
Indexer: Alexandra Nickerson permissionrequest@cengage.com
Print Buyer: Julio Esperas
Cover Designer: Roycroft Design/
www.roycroftdesign.com Library of Congress Control Number: 2010940363
Cover Photo: ª photolibrary/Richard ISBN-13: 978-1-111-53053-2
Cummins ISBN-10: 1-111-53053-x
Compositor: Integra Course Technology
20 Channel Center Street
Boston, MA 02210
Some of the product names and company
USA
names used in this book have been used for
identification purposes only and may be
trademarks or registered trademarks of their Cengage Learning is a leading provider of customized
respective manufacturers and sellers. learning solutions with office locations around the globe,
including Singapore, the United Kingdom, Australia, Mexico,
Any fictional data related to persons or
Brazil and Japan. Locate your local office at:
companies or URLs used throughout this
www.cengage.com/global
book is intended for instructional purposes
only. At the time this book was printed, any Cengage Learning products are represented in Canada by
such data was fictional and not belonging to Nelson Education, Ltd.
any real persons or companies.
To learn more about Course Technology, visit
Course Technology, a part of Cengage www.cengage.com/coursetechnology
Learning, reserves the right to revise this
Purchase any of our products at your local college store
publication and make changes from time to
or at our preferred online store www.cengagebrain.com
time in its content without notice.
The programs in this book are for
instructional purposes only. They have been
tested with care, but are not guaranteed for
any particular intent beyond educational
purposes. The author and the publisher do
not offer any warranties or representations,
nor do they accept any liabilities with respect
to the programs.

Printed in the United States of America


1 2 3 4 5 6 7 16 15 14 13 12 11 10

Copyright 2011 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.
Licensed to: iChapters User

TO

My Daughter

Shelly Malik

Copyright 2011 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.
Licensed to: iChapters User

Copyright 2011 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.
Licensed to: iChapters User

B RIEF C ONTENTS

PREFACE xix
1. An Overview of Computers and Programming Languages 1

2. Basic Elements of Java 25

3. Introduction to Objects and Input/Output 113

4. Control Structures I: Selection 177

5. Control Structures II: Repetition 249

6. Graphical User Interface (GUI) and Object-Oriented Design (OOD) 327

7. User-Defined Methods 383

8. User-Defined Classes and ADTs 465

9. Arrays 551

10. Inheritance and Polymorphism 639

11. Handling Exceptions and Events 723

12. Advanced GUIs and Graphics 783

13. Recursion 873

14. Searching and Sorting 907

APPENDIX A Java Reserved Words 939

APPENDIX B Operator Precedence 941

APPENDIX C Character Sets 945

APPENDIX D Additional Java Topics 949

APPENDIX E Answers to Odd-Numbered Exercises 997

INDEX 1023
Copyright 2011 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.
Licensed to: iChapters User

TABLE OF C ONTENTS

Preface xix

AN OVERVIEW OF COMPUTERS AND


1 PROGRAMMING LANGUAGES 1
Introduction 2

An Overview of the History of Computers 2

Elements of a Computer System 4


Hardware 4
Software 6

Language of a Computer 6

Evolution of Programming Languages 8

Processing a Java Program 10

Internet, World Wide Web, Browser, and Java 13

Programming with the Problem


Analysis–Coding–Execution Cycle 13

Programming Methodologies 19
Structured Programming 19
Object-Oriented Programming 19

Quick Review 21

Exercises 23

Copyright 2011 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.
Licensed to: iChapters User

Table of Contents | vii

BASIC ELEMENTS OF JAVA 25


2 A Java Program 26

Basics of a Java Program 28


Comments 29
Special Symbols 30
Reserved Words (Keywords) 30
Identifiers 31

Data Types 32
Primitive Data Types 32

Arithmetic Operators and Operator Precedence 36


Order of Precedence 39

Expressions 40
Mixed Expressions 41

Type Conversion (Casting) 43

class String 45
Strings and the Operator + 46

Input 48
Allocating Memory with Named Constants and Variables 48
Putting Data into Variables 51
Declaring and Initializing Variables 55
Input (Read) Statement 56
Reading a Single Character 61

Increment and Decrement Operators 64

Output 66

Packages, Classes, Methods, and the import Statement 71

Creating a Java Application Program 72

Debugging: Understanding and Fixing Syntax Errors 77

Programming Style and Form 80


Syntax 80

Avoiding Bugs: Consistent, Proper Formatting and


Code Walk-Through 84

Copyright 2011 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.
Licensed to: iChapters User

viii | Java Programming: From Problem Analysis to Program Design, Fifth Edition

More on Assignment Statements (Optional) 85

Quick Review 94

Exercises 97

Programming Exercises 106

INTRODUCTION TO OBJECTS AND INPUT/OUTPUT 113


3 Objects and Reference Variables 114

Using Predefined Classes and Methods in a Program 118


Dot Between Class (Object) Name and Class Member: A
Precaution 120

class String 121

Input/Output 129
Formatting Output with printf 129
Using Dialog Boxes for Input/Output 139
Formatting the Output Using the String Method format 146

File Input/Output 149


Storing (Writing) Output to a File 152

Debugging: Understanding Logic Errors and


Debugging with print or println Statements 163

Quick Review 165

Exercises 167

Programming Exercises 171

CONTROL STRUCTURES I: SELECTION 177


4 Control Structures 178

Relational Operators 180

Relational Operators and Primitive Data Types 181

Logical (Boolean) Operators and Logical Expressions 183

Order of Precedence 185


boolean Data Type and Logical (Boolean) Expressions 189

Copyright 2011 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.
Licensed to: iChapters User

Table of Contents | ix

Selection: if and if...else 190


One-Way Selection 190
Two-Way Selection 193
Compound (Block of) Statements 197
Multiple Selections: Nested if 198
Comparing if...else Statements with a Series
of if Statements 200
Short-Circuit Evaluation 201
Comparing Floating-Point Numbers for Equality:
A Precaution 202
Conditional Operator (? :) (Optional) 204

Avoiding Bugs by Avoiding Partially Understood


Concepts and Techniques 204

Program Style and Form (Revisited): Indentation 208

switch Structures 208

Avoiding Bugs by Avoiding Partially Understood


Concepts and Techniques (Revisited) 215

Comparing Strings 223


Strings, the Assignment Operator, and the Operator new 229

Quick Review 230

Exercises 232

Programming Exercises 241

CONTROL STRUCTURES II: REPETITION 249


5 Why Is Repetition Needed? 250

while Looping (Repetition) Structure 251


Designing while Loops 254
Counter-Controlled while Loops 255
Sentinel-Controlled while Loops 257
Flag-Controlled while Loops 263
EOF-Controlled while Loops 266
More on Expressions in while Statements 271

for Looping (Repetition) Structure 278

Copyright 2011 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.
Licensed to: iChapters User

x | Java Programming: From Problem Analysis to Program Design, Fifth Edition

do...while Looping (Repetition) Structure 288


Choosing the Right Looping Structure 293

break and continue Statements 293

Avoiding Bugs by Avoiding Patches 295

Debugging Loops 298

Nested Control Structures 299

Quick Review 304

Exercises 306

Programming Exercises 319

GRAPHICAL USER INTERFACE (GUI) AND


6 OBJECT-ORIENTED DESIGN (OOD) 327
Graphical User Interface (GUI) Components 328
Creating a Window 332
JFrame 332
Getting Access to the Content Pane 338
JLabel 339
JTextField 343
JButton 347

Object-Oriented Design 363


A Simplified OOD Methodology 364

Implementing Classes and Operations 370


Primitive Data Types and the Wrapper Classes 370

Quick Review 377

Exercises 378

Programming Exercises 381

USER-DEFINED METHODS 383


7 Predefined Methods 384
Using Predefined Methods in a Program 388

User-Defined Methods 391


Value-Returning Methods 391
Copyright 2011 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.
Licensed to: iChapters User

Table of Contents | xi

return Statement 395


Final Program 398

Flow of Execution 404

Void Methods 407

Primitive Data Type Variables as Parameters 411

Reference Variables as Parameters 414


Parameters and Memory Allocation 414
Reference Variables of the String Type as Parameters:
A Precaution 414
The class StringBuffer 418

Primitive Type Wrapper Classes as Parameters 421

Scope of an Identifier Within a Class 422

Method Overloading: An Introduction 427

Debugging: Using Drivers and Stubs 440

Avoiding Bugs: One-Piece-at-a-Time Coding 442

Quick Review 442

Exercises 445

Programming Exercises 456

USER-DEFINED CLASSES AND ADTS 465


8 Classes and Objects 466
Constructors 471
Unified Modeling Language Class Diagrams 472
Variable Declaration and Object Instantiation 473
Accessing Class Members 475
Built-in Operations on Classes 476
Assignment Operator and Classes: A Precaution 476
Class Scope 478

Copyright 2011 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.
Licensed to: iChapters User

xii | Java Programming: From Problem Analysis to Program Design, Fifth Edition

Methods and Classes 479


Definitions of the Constructors and Methods
of the class Clock 479

Classes and the Method toString 494

Copy Constructor 500

Static Members of a Class 501


static Variables (Data Members) of a Class 503

Finalizers 507

Accessor and Mutator Methods 507

Debugging—Designing and Documenting a Class 510

Reference this (Optional) 512


Cascaded Method Calls (Optional) 514

Inner Classes 517

Abstract Data Types 517

Quick Review 537

Exercises 538

Programming Exercises 547

ARRAYS 551
9 Why Do We Need Arrays? 552

Arrays 553
Alternate Ways to Declare an Array 555
Accessing Array Elements 555
Specifying Array Size during Program Execution 557
Array Initialization during Declaration 558
Arrays and the Instance Variable length 558
Processing One-Dimensional Arrays 559
Array Index Out of Bounds Exception 564
Declaring Arrays as Formal Parameters to Methods 564
Assignment Operator, Relational Operators, and Arrays:
A Precaution 565
Arrays as Parameters to Methods 567

Copyright 2011 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.
Licensed to: iChapters User

Table of Contents | xiii

Searching an Array for a Specific Item 572

Arrays of Objects 574


Arrays of string Objects 574
Arrays of Objects of Other Classes 576

Arrays and Variable Length Parameter List (Optional) 581

Two-Dimensional Arrays 589


Accessing Array Elements 591
Two-Dimensional Array Initialization during Declaration 594
Processing Two-Dimensional Arrays 595
Passing Two-Dimensional Arrays as Parameters to Methods 599

Multidimensional Arrays 603

class Vector (Optional) 616


Primitive Data Types and the class Vector 620
Vector Objects and the foreach Loop 620

Quick Review 621

Exercises 623

Programming Exercises 634

INHERITANCE AND POLYMORPHISM 639


10 Inheritance 640
Using Methods of the Superclass in a Subclass 642
Constructors of the Superclass and Subclass 648
Protected Members of a Class 657
Protected Access vs Package Access 660

class Object 661

Java Stream Classes 663

Polymorphism 664
Operator instanceof 670

Abstract Methods and Classes 674

Interfaces 681

Copyright 2011 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.
Licensed to: iChapters User

xiv | Java Programming: From Problem Analysis to Program Design, Fifth Edition

Polymorphism Via Interfaces 682

Composition (Aggregation) 684

Quick Review 709

Exercises 712

Programming Exercises 719

HANDLING EXCEPTIONS AND EVENTS 723


11 Handling Exceptions Within a Program 724
Java’s Mechanism of Exception Handling 727
try/catch/finally Block 728

Java Exception Hierarchy 733

Java’s Exception Classes 736

Checked and Unchecked Exceptions 741

More Examples of Exception Handling 743


class Exception and the Operator instanceof 746

Rethrowing and Throwing an Exception 749

Method printStackTrace 753

Exception-Handling Techniques 755


Terminate the Program 755
Fix the Error and Continue 756
Log the Error and Continue 757

Creating Your Own Exception Classes 758

Event Handling 760

Quick Review 775

Exercises 777

Programming Exercises 781

Copyright 2011 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.
Licensed to: iChapters User

Table of Contents | xv

ADVANCED GUIS AND GRAPHICS 783


12 Applets 787

class Font 791

class Color 794

class Graphics 800


Converting an Application Program to an Applet 808

Additional GUI Components 811


JTextArea 811
JCheckBox 816
JRadioButton 823
JComboBox 828
JList 833

Layout Managers 839


FlowLayout 840
BorderLayout 843

Menus 844

Key and Mouse Events 847


Key Events 848
Mouse Events 850

Quick Review 865

Exercises 866

Programming Exercises 868

RECURSION 873
13
Recursive Definitions 874
Direct and Indirect Recursion 876
Infinite Recursion 877
Designing Recursive Methods 877

Problem Solving Using Recursion 878


Tower of Hanoi: Analysis 887

Recursion or Iteration? 888

Copyright 2011 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.
Licensed to: iChapters User

xvi | Java Programming: From Problem Analysis to Program Design, Fifth Edition

Quick Review 896

Exercises 897

Programming Exercises 901

SEARCHING AND SORTING 907


14
List Processing 908
Searching 908
Selection Sort 909
Insertion Sort 913
Binary Search 917

Quick Review 934

Exercises 934

Programming Exercises 936

APPENDIX A: JAVA RESERVED WORDS 939

APPENDIX B: OPERATOR PRECEDENCE 941

APPENDIX C: CHARACTER SETS 945


ASCII (American Standard Code for Information
Interchange), the First 128 Characters of the
Unicode Character Set 945
EBCDIC (Extended Binary Coded Decimal
Interchange Code) 946

APPENDIX D: ADDITIONAL JAVA TOPICS 949


Binary (Base 2) Representation of a Nonnegative Integer 949
Converting a Base 10 Number to a Binary Number (Base 2) 949
Converting a Binary Number (Base 2) to Base 10 951
Converting a Binary Number (Base 2) to Octol (Base 8)
and Hexdecimal (Base 16) 952

Copyright 2011 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.
Licensed to: iChapters User

Table of Contents | xvii

Executing Java Programs Using the Command-Line


Statements 954
Setting the Path in Windows 7.0 (Professional) 954
Executing Java Programs 959
Java Style Documentation 964

Creating Your Own Packages 966


Multiple File Programs 969

Formatting the Output of Decimal Numbers Using


the class DecimalFormat 969

Packages and User-Defined Classes 972


Primitive Type Classes 972
Class: IntClass 972
Class: LongClass 976
Class: CharClass 977
Class: FloatClass 977
Class: DoubleClass 978
Class: BooleanClass 979
Using Primitive Type Classes in a Program 980

Enumeration Types 981

APPENDIX E: ANSWERS TO ODD-NUMBERED


EXERCISES 997
Chapter 1 997

Chapter 2 998

Chapter 3 1001

Chapter 4 1002

Chapter 5 1004

Chapter 6 1007

Chapter 7 1008

Chapter 8 1010

Chapter 9 1014

Copyright 2011 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.
Licensed to: iChapters User

xviii | Java Programming: From Problem Analysis to Program Design, Fifth Edition

Chapter 10 1016

Chapter 11 1018

Chapter 12 1019

Chapter 13 1020

Chapter 14 1020

INDEX 1023

Copyright 2011 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.
Licensed to: iChapters User

P REFACE TO THE F IFTH


E DITION

Welcome to Java Programming: From Problem Analysis to Program Design, Fifth Edition.
Designed for a first Computer Science (CS1) Java course, this text will provide a breath of
fresh air to you and your students. The CS1 course serves as the cornerstone of the Computer
Science curriculum. My primary goal is to motivate and excite all programming students,
regardless of their level. Motivation breeds excitement for learning. Motivation and excite-
ment are critical factors that lead to the success of the programming student. This text is the
culmination and development of my classroom notes throughout more than fifty semesters of
teaching successful programming.
Warning: This text can be expected to create a serious reduction in the demand for program-
ming help during your office hours. Other side effects include significantly diminished student
dependency on others while learning to program.

The primary focus in writing this text is on student learning. Therefore, in addition to clear
explanations, we address the key issues that otherwise impede student learning. For example, a
common question that arises naturally during an early programming assignment is: ‘‘How
many variables and what kinds are needed in this program?’’ We illustrate this important and
crucial step by helping students learn why variables are needed and how data in a variable is
manipulated. Next students learn that the analysis of the problem will spill the number and
types of the variables. Once students grasp this key concept, control structures (selection and
loops) become easier to learn. The second major impediment in learning programming is
parameter passing. We pay special attention to this topic. First students learn how to use
predefined methods and how actual and formal parameters relate. Next students learn about
user-defined methods. They see visual diagrams that help them learn how methods are called
and how formal parameters affect actual parameters. Once students have a clear understanding
of these two key concepts, they readily assimilate advanced topics.
The topics are introduced at a pace that is conducive to learning. The writing style is friendly,
engaging, and straightforward. It parallels the learning style of the contemporary CS1 student.
Before introducing a key concept, the student learns why the concept is needed, and then sees
examples illustrating the concept. Special attention is paid to topics that are essential in
mastering the Java programming language and in acquiring a foundation for further study
of computer science.

Copyright 2011 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.
Licensed to: iChapters User

xx | Java Programming: From Problem Analysis to Program Design, Fifth Edition

Other important topics include debugging techniques and techniques for avoiding programming
bugs. When a beginner compiles his/her first program and sees that the number of errors exceeds the
length of this first program, he/she becomes frustrated by the plethora of errors, only some of which
can be interpreted. To ease this frustration and help students learn to produce correct programs,
debugging and bug avoidance techniques are presented systematically throughout the text.

Changes in the Fifth Edition


The main changes are:
• In the fifth edition, new debugging sections have been added and some of the old
ones have been rewritten. These sections are indicated with a debugging icon.
• The fifth edition contains more than 125 new exercises, 27 new programming
exercises, and numerous new examples spread throughout the book.
• In Chapters 6 and 12 the GUI figures have been captured and replaced in Windows 7
Professional environment.
• Appendix D contains screen images illustrating how to compile and execute a Java
program using the command-line statements as well as how to set the path in
Windows 7 Professional environment.
These changes were implemented based on comments from the text reviewers of the fifth
edition. The source code and the programming exercises are developed and tested using Java
6.0 and the version of Java 7.0 available at the time this book was being typeset.

Approach
Once conceived as a Web programming language, Java slowly but surely found its way into
classrooms where it now serves as a first programming language in computer science curricula
(CS1). Java is a combination of traditional style programming—programming with a non-
graphical user interface—and modern style programming with a graphical user interface
(GUI). This book introduces you to both styles of programming. After giving a brief
description of each chapter, we discuss how to read this book.
Chapter 1 briefly reviews the history of computers and programming languages. The reader
can quickly skim and become familiar with some of the hardware and software components of
the computer. This chapter also gives an example of a Java program and describes how a Java
program is processed. The two basic problem-solving techniques, structured programming
and object-oriented design, are also presented.
After completing Chapter 2, students become familiar with the basics of Java and are ready to
write programs that are complicated enough to do some computations. The debugging section
in this chapter illustrates how to interpret and correct syntax errors.
The three terms that you will encounter throughout the book are—primitive type variables,
reference variables, and objects. Chapter 3 makes clear distinctions between these terms and
sets the tone for the rest of the book. An object is a fundamental entity in an object-oriented

Copyright 2011 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.
Licensed to: iChapters User

Preface to the Fifth Edition | xxi

programming language. This chapter further explains how an object works. The class
String is one of the most important classes in Java. This chapter introduces this class and
explains how various methods of this class can be used to manipulate strings. Because input/
output is fundamental to any programming language, it is introduced early, and is covered in
detail in Chapter 3. The debugging section in this chapter illustrates how to find and correct
logical errors.
Chapters 4 and 5 introduce control structures used to alter the sequential flow of execution.
The debugging sections in these chapters discuss and illustrate logical errors associated with
selection and looping structures.
Java is equipped with powerful yet easy-to-use graphical user interface (GUI) components
to create user-friendly graphical programs. Chapter 6 introduces various GUI components
and gives examples of how to use these components in Java application programs. Because
Java is an object-oriented programming language, the second part of Chapter 6 discusses
and gives examples of how to solve various problems using object-oriented design
methodology.
Chapter 7 discusses user-defined methods. Parameter passing is a fundamental concept in any
programming language. Several examples, including visual diagrams, help readers understand
this concept. It is recommended that readers with no prior programming background spend
extra time on this concept. The debugging section in this chapter discuss how to debug a
program using stubs and drivers.
Chapter 8 discusses user-defined classes. In Java, a class is an important and widely used
element. It is used to create Java programs, group related operations, and it allows users to
create their own data types. This chapter uses extensive visual diagrams to illustrate how
objects of classes manipulate data.
Chapter 9 describes arrays. This chapter also introduces variable length formal parameter lists.
In addition, this chapter introduces foreach loops and explains how this loop can be used to
process the elements of an array. This chapter also discusses the sequential searching algorithm
and the class Vector.
Inheritance is an important principle of object-oriented design. It encourages code reuse.
Chapter 10 discusses inheritance and gives various examples to illustrate how classes are
derived from existing classes. In addition, this chapter also discusses polymorphism, abstract
classes, inner classes, and composition.
An occurrence of an undesirable situation that can be detected during program execution is
called an exception. For example, division by zero is an exception. Java provides extensive
support for handing exceptions. Chapter 11 shows how to handle exceptions in a program.
Chapter 11 also discusses event handling, which was introduced in Chapter 6. Chapter 12
picks up the discussion of GUI components started in Chapter 6. This chapter introduces
additional GUI components and discusses how to create applets.
Chapter 13 introduces recursion. Several examples illustrate how recursive methods
execute.

Copyright 2011 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.
Licensed to: iChapters User

xxii | Java Programming: From Problem Analysis to Program Design, Fifth Edition

Chapter 14 discusses a binary search algorithm as well as bubble sort, selection sort, insertion
sort, and quick sort algorithms. Additional content covering the sorting algorithms bubble sort
and quick sort is provided online at www.cengagebrain.com.
Appendix A lists the reserved words in Java. Appendix B shows the precedence and
associativity of the Java operators. Appendix C lists the ASCII (American Standard Code
for Information Interchange) portion of the Unicode character set as well as the EBCDIC
(Extended Binary Code Decimal Interchange) character set.
Appendix D contains additional topics in Java. The topics covered are converting a base 10
number to binary (base 2) number and vice versa, converting a number from base 2 to base 8 (base
16) and vice versa, how to compile and execute a Java program using command line statements,
how to create Java style documentation of the user-defined classes, how to create packages, how to
use user-defined classes in a Java program, and enum type. Appendix E gives answers to the odd-
numbered exercises in the text. Those odd-numbered exercises with very long solutions will not
be in the text, but will be provided to students online at www.cengagebrain.com.

How To Use This Book


Java is a complex and very powerful language. In addition to traditional (non-GUI) program-
ming, Java provides extensive support for creating programs that use a graphical user interface
(GUI). Chapter 3 introduces graphical input and output dialog boxes. Chapter 6 introduces
the most commonly used GUI components such as labels, buttons, and text fields. More
extensive coverage of GUI components is provided in Chapter 12.
This book can be used in two ways. One way is an integrated approach in which readers learn
how to write both non-GUI and GUI programs as they learn basic programming concepts
and skills. The other approach focuses on illustrating fundamental programming concepts
with non-GUI programming first, and later incorporating GUI components. The recom-
mended chapter sequence for each of these approaches is as follows:
• Integrated approach: Study all chapters in sequence.
• Non-GUI first, then GUI: Study Chapters 1–5 in sequence. Then study Chapters
7–11 and Chapters 13 and 14. This approach initially skips Chapters 6 and 12, the
primary GUI chapters. After studying Chapters 1–5, 7–11, 13, and 14, the reader can
come back to study Chapters 6 and 12, the GUI chapters. Also note that Chapter 14
can be studied after Chapter 9.
If you choose the second approach, it should also be noted that the Programming Examples in
Chapters 8 and 10 are developed first without any GUI components, and then the programs
are extended to incorporate GUI components. Also, if Chapter 6 is skipped, the reader can skip
the event handling part of Chapter 11. Chapter 13 (recursion) contains two Programming
Examples: one creates a non-GUI application program, while the other creates a program that
uses GUI. If you skip Chapters 6 and 12, you can skip the GUI part of the Programming
Examples in Chapters 8, 10, 11, and 13. Once you have studied Chapter 6 and 12, you can
study the GUI part of the Programming Examples of Chapters 8, 10, 11, and 13.

Copyright 2011 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.
Licensed to: iChapters User

Preface to the Fifth Edition | xxiii

Figure 1 shows a chapter dependency diagram for this book. Solid arrows indicate that the
chapter at the beginning of the arrow is required before studying the chapter at the end of the
arrow. A dotted arrow indicates that the chapter at the beginning of the arrow is not essential
to studying the chapter at the end of the dotted arrow.

Chapter 1

Chapter 2

Chapter 3

Chapter 4

Chapter 5

Chapter 6 Chapter 7

Chapter 8 Chapter 9

Chapter 10 Chapter 14

Chapter 11

Chapter 12

Chapter 13

A dotted arrow means that the chapter is not essential to studying the following chapter.

FIGURE 1 Chapter dependency diagram

All source code and solutions have been written, compiled, and quality assurance tested
with Java 6.0 and the version of Java 7.0 available at the time this book was being typeset.

Copyright 2011 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.
Licensed to: iChapters User

FEATURES OF THE BOOK

Four-color
interior design
shows
accurate code
and related
comments.

Copyright 2011 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.
Licensed to: iChapters User

The debugging
sections show
how to find
and correct
syntax and
semantic
(logical)
errors.

Copyright 2011 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.
Licensed to: iChapters User

More than
250 visual
diagrams,
both
extensive and
exhaustive,
illustrate difficult
concepts.

Copyright 2011 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.
Licensed to: iChapters User

Numbered Examples
illustrate the key
concepts with their
relevant code. The
programming code in
these examples is
followed by a Sample
Run. An explanation
then follows that
describes what each
line in the code does.

Copyright 2011 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.
Licensed to: iChapters User

Notes highlight
important facts
about the concepts
introduced in the
chapter.

Copyright 2011 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.
Licensed to: iChapters User

Programming
Examples are
complete programs
featured in each
chapter. These
examples include the
accurate, concrete
stages of Input,
Output, Problem
Analysis and Algorithm
Design, and a
Complete Program
Listing.

Copyright 2011 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.
Licensed to: iChapters User

Exercises further
reinforce learning
and ensure that
students have, in
fact, mastered the
material.

Copyright 2011 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.
Licensed to: iChapters User

Programming
Exercises challenge
students to write
Java programs with
a specified
outcome.

Copyright 2011 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.
Licensed to: iChapters User

Copyright 2011 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.
Licensed to: iChapters User

S UPPLEMENTAL
R ESOURCES

The following supplemental materials are available when this book is used in a classroom setting.
Most instructor teaching tools, outlined below, are available with this book on a single
CD-ROM, and are also available for instructor access at login.cengage.com.

Electronic Instructor’s Manual


The Instructor’s Manual that accompanies this textbook includes:
• Additional instructional material to assist in class preparation, including suggestions
for lecture topics.
• Solutions to all the end-of-chapter materials, including the Programming Exercises.

ExamView!
This textbook is accompanied by ExamView, a powerful testing software package that allows
instructors to create and administer printed, computer (LAN-based), and Internet exams.
ExamView includes hundreds of questions that correspond to the topics covered in this text,
enabling students to generate detailed study guides that include page references for further
review. These computer-based and Internet testing components allow students to take exams
at their computers, and save the instructor time because each exam is graded automatically.

PowerPoint Presentations
Microsoft PowerPoint slides are available for each chapter. These slides are provided as a teaching
aid for classroom presentations, either to make available to students on the network for chapter
review, or to be printed for classroom distribution. Instructors can add their own slides for
additional topics that they introduce to the class.

Distance Learning
Course Technology is proud to present online courses in WebCT and Blackboard to provide
the most complete and dynamic learning experience possible. For more information on how

Copyright 2011 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.
Licensed to: iChapters User

xxxiv | Java Programming: From Problem Analysis to Program Design, Fifth Edition

to bring distance learning to your course, contact your local Course Technology sales
representative.

Source Code
The source code is available for students at www.cengagebrain.com. At the cengagebrain.com home
page, search for the ISBN of your title (from the back cover of your book) using the search
box at the top of the page. This will take you to the product page where these resources can
be found. The source code is also available on the Instructor Resources CD-ROM. The
input files needed to run some of the programs are also included with the source code.

Additional Student Files


The Additional Student Files referenced throughout the text are available on the Instructor
Resources CD. Students can download these files directly at www.cengagebrain.com. At the
cengagebrain.com home page, search for the ISBN of your title using the search box at the top
of the page. This will take you to the product page where these resources can be found. Click
the Access Now link below the book cover to find all study tools and additional files available
directly to students. Additional Student Files appear on the left navigation and provide access
to additional Java programs, selected solutions, and more.

Solution Files
The solution files for all programming exercises are available for instructor download at
http://login.cengage.com and are also available on the Instructor Resources CD-ROM. The
input files needed to run some of the programming exercises are also included with the
solution files.

Copyright 2011 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.
Licensed to: iChapters User

A CKNOWLEDGMENTS

There are many people I must thank who, in one way or another, contributed to the success
of this book. First, I would like to thank those who e-mailed numerous comments that helped
to improve on the fourth edition. I am thankful to Professors S.C. Cheng and Randall Crist
for constantly supporting this project.
I owe a great deal to the following reviewers, who patiently read each page of every chapter
of the current version and made critical comments that helped to improve the book:
Nadimpalli Mahadev, Fitchburg State College and Baoqiang Yan, Missouri Western State
University. Additionally, I would like to thank Brian Candido, Springfield Technical Com-
munity College, for his review of the proposal package. The reviewers will recognize that
their suggestions have not been overlooked and, in fact, made this a better book.
Next, I express thanks to Brandi Shailer, Acquisitions Editor, for recognizing the importance
and uniqueness of this project. All this would not have been possible without the careful
planning of Senior Product Manager Alyssa Pratt. I extend my sincere thanks to Alyssa, as well
as to Content Project Manager, Lisa Weidenfeld. I also thank Sreejith Govindan of Integra
Software Services for assisting us in keeping the project on schedule. I would like to thank
Chris Scriver and Serge Palladino of the MQA department of Course Technology for patiently
and carefully proofreading the text, testing the code, and discovering typos and errors.
I am thankful to my parents for their blessings.
Finally, I am thankful to the support of my wife Sadhana, and especially my daughter Shelly,
to whom this book is dedicated. They cheered me up whenever I was overwhelmed during
the writing of this book.
We welcome any comments concerning the text. Comments may be forwarded to the
following e-mail address: malik@creighton.edu.
D.S. Malik

Copyright 2011 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.
Licensed to: iChapters User

Copyright 2011 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.
Licensed to: iChapters User

APPENDIX A
J AVA R ESERVED
W ORDS

The following table lists Java reserved words in alphabetical order.


abstract else interface switch
assert enum long synchronized
boolean extends native this
break false new throw
byte final null throws
case finally package transient
catch float private true
char for protected try
class goto public void
const if return volatile
continue implements short while
default import static
do instanceof strictfp
double int super

The reserved words const and goto are not currently in use.

939
Copyright 2011 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.
Licensed to: iChapters User

Copyright 2011 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.
Licensed to: iChapters User

APPENDIX B
O PERATOR
P RECEDENCE

The following table shows the precedence of operators in Java from highest to lowest,
and their associativity.

Operator Description Precedence Level Associativity

. Object member access 1 Left to right


[] Array subscripting 1 Left to right
(parameters) Method call 1 Left to right
++ Postincrement 1 Left to right
-- Postdecrement 1 Left to right

++ Preincrement 2 Right to left


-- Predecrement 2 Right to left
+ Unary plus 2 Right to left
- Unary minus 2 Right to left
! Logical not 2 Right to left
! Bitwise not 2 Right to left

new Object instantiation 3 Right to left


(type) Type conversion 3 Right to left

* Multiplication 4 Left to right


/ Division 4 Left to right
% Remainder (modulus) 4 Left to right

941
Copyright 2011 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.
Licensed to: iChapters User

942 | Appendix B: Operator Precedence

Operator Description Precedence Level Associativity

+ Addition 5 Left to right


- Subtraction 5 Left to right
+ String concatenation 5 Left to right
<< Left shift 6 Left to right
Right shift with sign
>> 6 Left to right
extension
Right shift with zero
>>> 6 Left to right
extension

< Less than 7 Left to right


<¼ Less than or equal to 7 Left to right
> Greater than 7 Left to right
>¼ Greater than or equal to 7 Left to right
instanceof Type comparison 7 Left to right

¼¼ Equal to 8 Left to right


!¼ Not equal to 8 Left to right

& Bitwise AND 9 Left to right


& Logical AND 9 Left to right

^ Bitwise XOR 10 Left to right


^ Logical XOR 10 Left to right

| Bitwise OR 11 Left to right


| Logical OR 11 Left to right

&& Logical AND 12 Left to right

Copyright 2011 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.
Licensed to: iChapters User

Appendix B: Operator Precedence | 943

Operator Description Precedence Level Associativity

|| Logical OR 13 Left to right

?: Conditional operator 14 Right to left

¼ Assignment 15 Right to left


Compound Operators
Addition, then
+¼ 15 Right to left
assignment
String concatenation,
+¼ 15 Right to left
then assignment
Subtraction, then
-¼ 15 Right to left
assignment
Multiplication, then
*¼ 15 Right to left
assignment
Division, then
/¼ 15 Right to left
assignment
Remainder, then
%¼ 15 Right to left
assignment
Bitwise left shift, then
<<¼ 15 Right to left
assignment
Bitwise right shift, then
>>¼ 15 Right to left
assignment
Bitwise unsigned-right
>>>¼ 15 Right to left
shift, then assignment
Bitwise AND, then
&¼ 15 Right to left
assignment
Logical AND, then
&¼ 15 Right to left
assignment
Bitwise OR, then
|¼ 15 Right to left
assignment
Logical OR, then
|¼ 15 Right to left
assignment
Bitwise XOR, then
^¼ 15 Right to left
assignment
Logical XOR, then
^¼ 15 Right to left
assignment

Copyright 2011 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.
Licensed to: iChapters User

Copyright 2011 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.
Licensed to: iChapters User

APPENDIX C
C HARACTER S ETS

This appendix lists and describes the character sets for ASCII (American Standard Code
for Information Interchange), which also comprises the first 128 characters of the Uni-
code character set, and EBCDIC (Extended Binary Coded Decimal Interchange Code).

ASCII (American Standard Code for Information Interchange),


the First 128 Characters of the Unicode Character Set
The following table shows the first 128 characters of the Unicode (ASCII) character set.

ASCII

0 1 2 3 4 5 6 7 8 9
0 nul soh stx etx eot enq ack bel bs ht
1 lf vt ff cr so si dle dc1 dc2 dc3
2 dc4 nak syn etb can em sub esc fs gs
3 rs us b ! " # $ % & '
4 ( ) * + , - . / 0 1
5 2 3 4 5 6 7 8 9 : ;
6 < ¼ > ? @ A B C D E
7 F G H I J K L M N O
8 P Q R S T U V W X Y
9 Z [ \ ] ^ _ ` a b c
10 d e f g h i j k l m
11 n o p q r s t u v w
12 x y z { | } " del

945
Copyright 2011 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.
Discovering Diverse Content Through
Random Scribd Documents
true of the area which contains a number of such tumors, i. e., the
so-called pile-bearing area. Hence, surgeons of the largest
experience have practically discarded the more bungling methods
and have applied to these conditions the same radical measures
which they recommend elsewhere.
One important feature which should always be practised is
thorough dilatation of the sphincter, not only for reasons above
described, but because of the facility with which the surgeon then
exposes the diseased tissues. Any distinct tumor or series of them
may, for instance, be seized, isolated, and dissected out, either by
an elliptical incision of the mucosa or by a more blunt dissection with
scissors. The base, or pedicle, if sufficiently large to justify it, may be
ligated before the incision is completed, after which catgut sutures
may be used to close the opening in the mucosa. When the tumor is
small the suture may be made to include the bleeding points so that
even a ligature is not required. A more radical method of extending
this same principle to the entire pile-bearing area, especially when
prolapsed, or to so much of it as is affected, is the so-called
Whitehead’s operation of excision, which practically consists in
trimming off a ring of exposed mucosa, with its clusters of enlarged
and more or less pendulous veins. This ring extends from the
mucocutaneous border, at the verge of the anus, to a point perhaps
1¹⁄₂ inches above, the intent being to separate the mucosa and the
tumors from the fibers of the sphincter, which can be practically
effected in such a way that sphincter control is not lost. Hemorrhage
will be free for a few moments, but is always within control. Larger
vessels which spurt may be twisted or tied, while oozing surfaces are
included within the row of catgut sutures, which is later placed in
such a way as to unite the divided mucous tube with the skin border
at the anus. The operation is, in effect, an annular excision of the
lining of the rectum, and as such proves satisfactory. There is about
it this temporary disadvantage that the pile-bearing area thus
removed is also the sensitive area, and that for a few weeks, at least
until nerve communications have been reëstablished, there is a lack
of peculiar or normal sensibility about the parts which is annoying,
and may perhaps lead to some incontinence, but this soon passes
away. The measure is the most satisfactory of all for well-marked
cases of hemorrhoids associated with more or less ulceration and
prolapse.
An occasional dilatation, scattered here and there around the
lower end of the rectum, perhaps with a mild degree of ulceration, is
usually very satisfactorily treated by a method which it must be
confessed would be rarely used on the exterior of the body, and yet
which proves quite serviceable here, namely, the actual cautery. The
consequences of its application are obliteration of the vein, cicatricial
contraction of the overstretched tissues and eventual relief.
Other methods of operation include the use of the clamp and
cautery for removal of considerable masses, a method ordinarily less
satisfactory than excision, and the use of the ligature, with or
without incision of the mucosa at the base of the tumor, it being
thus cauterized and expected to separate by sloughing, an uncertain
procedure. None of these methods, nor others not worth
mentioning, compare with the newer methods of excision.
Much has been recently written concerning the advantage of local
anesthesia in doing these operations. This seems to have been
advocated largely for effect, although external tumors can be treated
by cocaine applications or by the ordinary injections of cocaine or
one of its substitutes. It is claimed that the infiltration of the
surrounding tissues with normal salt solution affords an effective
local anesthetic. Mere local anesthesia is not sufficient for thorough
work upon parts not easily visible, and the actual stretching of the
sphincter is half the battle in dealing with these conditions. This
cannot be thoroughly accomplished without general anesthesia.
Consequently for any well-marked hemorrhoidal condition
chloroform offers decidedly the preferable method, not alone from
considerations of comfort, but from the standpoint of permitting
more thorough and effective work to be done.
After these operations it is advisable to place within the grasp of
the anus a stiff rubber tube wrapped with gauze. It permits the
escape of flatus without distress to the patient, and it effects a
better coaptation of surfaces recently united by suture than would
otherwise be secured. Such a tube Fig. 593
may be left in situ for from six to
thirty-six hours.

TUMORS OF THE RECTUM.


The rectum is the frequent site,
more especially in children, of
polypoid degenerations similar to
those seen in the nose. In
consequence there are formed the
so-called rectal polypi, which, in
origin, consistence, and course
correspond to the common nasal
polypi. Such a pedunculated tumor
may attain considerable size,
especially when solitary, while, on
the other hand, the mucosa may be
studded with small pedunculated
growths, giving the appearance
represented in Fig. 593.
Pathologically these polypi are
originally of myxomatous or
adenomatous type. They may bleed
easily and may be passed with
stool. In their multiple and smaller
expressions they give rise rather to
rectal uneasiness and tenesmus
than to more distinct symptoms. On
the other hand an isolated tumor,
so pedunculated as to become
gradually stretched out, may attain
considerable size and give rise to all
the sensations of a foreign body in
the rectum, with constant tenesmus
and desire to expel it, while it may
even present at the anus or bleed
freely.
Only exceptionally will these
tumors be recognized previous to
examination, which, however,
should easily disclose their
characteristics. Isolated polypi
should be removed, either by being
twisted off or by excision and
ligature of their bases. General
polypoid degeneration may be
treated with the curette or with the
actual cautery. In all these
instances surgical intervention in
some form will be required.
Other benign tumors in the
rectum are mainly of the
adenomatous type. Owing to their
location it is rare that they are seen
early by one competent to judge of
them. In consequence the surgeon
sees them usually as more or less
ulcerated, sometimes extensive
growths, perhaps bleeding freely,
and much changed by maceration
and by compression from their
original condition.
In such cases it becomes a
question of importance to
distinguish between the benign and
the cancerous growths. This is not
always easily done, especially when
they are high up and ulcerated. The
matter is usually decided by the
presence or absence of actual
infiltration around the base of the
growth, and perhaps the Multiple polypi of rectum. (Potherat.)
involvement of lymph nodes. A
movable tumor with an infiltrated base is usually clinically benign,
nevertheless it should be radically removed. It is in many of these
instances that one may see expressions of transformation of
adenoma into carcinoma.
Cancer of the Rectum.—This will be considered here rather
from its clinical side; hence what is said
refers alike to sarcoma and carcinoma, the latter being far more
common. Carcinoma of the rectum may assume the type either of
epithelioma, as when it begins low and spreads upward, or of
adenocarcinoma, when it arises from that portion of the tube not
lined with squamous epithelium.
It usually begins insidiously, and for a considerable length of time
furnishes scarcely any recognizable symptom. The first indications
noticed by the patient are usually more or less frequency of stool,
with tenesmus, and the passage of mucus, perhaps stained with
blood, rather than of fecal matter. By the time those conditions are
noticed there will usually be more or less mechanical difficulty of
defecation, due to the presence of the tumor and obstruction of the
rectal tube. Pain may be a long-deferred feature, and local soreness
may be absent until late in the case or until its terminal stage, when
the growth is above the peculiarly sensitive part of the rectum, i. e.,
when it does not approach to within 1¹⁄₂ inches of the sphincter. As
time goes on there is more and more suffering in the rectum, with
backache, referred pain, while the tenesmus and other local
conditions cause increasing distress. It often happens that it is not
until this period is reached that the patient consults a physician, and
then he usually goes with the statement that he is suffering from
piles.
Fig. 594

Epithelioma of anus and rectum. (Grant.)

So frequently is this the case, and so prone are many practitioners


to accept such a statement, that the proper examination which
should permit the recognition of the condition is perhaps not made
until the patient is really in a pitiable condition. I do not recall ever
having seen a case of cancer of the rectum which had not been
regarded, by some physician as piles, and in most cases locally
treated by him, usually without any adequate local examination, and
usually also until the time had passed when a radical operation could
be practised with any degree of hope. The first examination at least
will be digital, and if the malignant growth be within reach of the
finger it should be possible to appreciate it, to estimate its size,
degree of attachment, and the amount of infiltration, as well as the
extent to which it is breaking down. A soft, rapidly growing cancer
will give a fungous sensation to the finger, while the more dense,
scirrhous forms produce hard masses, growing in irregular shapes,
sometimes involving one side of the bowel, sometimes appearing in
annular form, and tending sooner or later to produce malignant
destruction. The only difficulty would be in cases seen exceptionally
early or in those beyond reach. The circumstances above detailed
should lead to a careful proctoscopic examination with suitable
instruments, perhaps in the knee-chest position, when the growth is
not easily appreciated from below. Any complaint of tenesmus, with
discharge of blood and mucus, with more or less pain and
tenderness, local or referred, demands an examination sufficiently
careful to reveal the nature and extent of the lesion and indicate the
treatment. If such an examination call for an anesthetic, it should be
administered. Practically every rectal cancer is a malignant ulcer by
the time it is recognized, ulceration being favored by warmth and
moisture.
Treatment.—There are few malignant lesions anywhere about the
body which require more good judgment in treatment than cases of
cancer of the rectum. So much depends upon their location, their
extent, the degree of infiltration, the age and general condition of
the patient, that it is almost impossible to lay down succinct rules.
The question of treatment hinges, first, upon the location and extent
of the lesion; is it operable or is it not? When the lymph nodes of the
pelvis or the groin are noticeably involved it is practically too late,
under any circumstances, to hold out prospect of radical cure. When
the disease has extended far above reach of the finger it is again
late to expect much even from radical measures. When the prostate,
the floor of the bladder, the vagina, or any of the pelvic viscera are
involved it is again too late to justify them. There are wide
differences of opinion between surgeons as to the propriety of
extensive operations in serious cases. Mild cases are certainly much
benefited and even actually cured by early and thorough removal,
but this occurs too infrequently, because such cases are rarely seen
sufficiently early.
The class of cases universally acknowledged to be inoperable, so
far as radical measures are concerned, are nevertheless much
benefited and their lives prolonged by a colostomy, the effect being
to provide an easy and manageable outlet for fecal discharge, and to
avoid the irritation and attendant difficulties associated with an
obstructed and malignantly ulcerated rectal outlet. The surgeon has
to select between some method of excision and colostomy. My own
opinion is growing in favor of the latter, save when the prospect of
complete excision is good. The opening is more manageable, the
progress of the disease seems much checked, patients have better
fecal control and live in far greater comfort, while their lives are
placed in less jeopardy, and, in general, are actually prolonged. Thus
a colostomy performed in a well-marked case of inoperable cancer of
the rectum may permit of prolongation of life for two or three years,
something not often attained by any other method of treatment.
Of the various radical operations some are made from below, i. e.,
by the perineal route, some by the so-called sacral route, and some
from above. Of the latter it may be said that occasionally an annular
cancer of the rectum is seen so favorably located that by opening
the abdomen with the patient in the Trendelenburg position it is
possible to make a complete excision of the growth, to remove
enlarged lymph nodes, and to make an end-to-end reunion with
success. In a case in my own practice nearly six years have elapsed
since this operation was done, and the patient, a young woman, is
still absolutely free from the disease.
Through the perineum the lower portion of the rectum may be
attacked either by splitting the sphincter and dividing it posteriorly,
completely dissecting out the gut from its surroundings, removing all
infiltrated tissue, and then, by dividing the bowel above the growth,
amputating the lower part. It may be possible to bring down the
upper end and attach it to the mucocutaneous border of the anus,
reuniting the divided sphincter, and aiming for a restoration to
something like the original condition, which under quite favorable
conditions is attainable. At other times it will be impracticable to thus
attach the lower end of the tube because it has been too much
shortened, and in these cases it should be brought out through a
posterior incision just below the tip of the coccyx, or higher up if the
bone has been removed. Here the rectal outlet is placed posteriorly,
but is devoid of a sphincter. Something like sphincteric action can be
provided by giving it a third or half of a revolution on its axis before
fastening it to the external wound. After this expedient more or less
control of solid fecal matter is afforded.
The more complete and radical operations, associated with the
names of Kraske and other operators, include removal of the coccyx,
and of the lower portion of the sacrum, which are usually completely
excised, although certain “trap-door” operations have been devised.
If the sacrum be not cut away above the third sacral foramen there
is not much damage done to the nerves, while sufficient room is
afforded for any removal that is justifiable. Some operators open the
peritoneum, others attempt to avoid it. If the growth be attached to
that membrane it becomes necessary. If peritoneal invasion can be
avoided it is desirable. It is possible to completely expose the
contents of the pelvis through such an opening, while from this
direction, the gut being withdrawn after the peritoneum is divided,
the pouch of Douglas may be opened and further removal of
diseased tissue be effected. In all these operations the endeavor
should be to disturb the mesosigmoid and the mesorectum as little
as possible, in order to not interfere with blood supply, for reasons
already mentioned when discussing the mesentery.
In all these operations contamination of the wound should be
avoided, especially of the peritoneum, by clamping or ligating the
bowel, or by amply packing and by every possible additional
precaution. Bowel should be divided between two clamps and the
divided edges at once thoroughly cleansed with compresses and
with hydrogen peroxide.
One may read in the works on operative surgery descriptions of
most extensive and elaborate operations of this general character,
and of extensive and even daring feats of removal, where portions of
the bladder, of the tubes, of the ovaries, even the uterus, have been
removed. It has seemed to me that the surgeon should avoid
operative gymnastics, especially in this region, so far as possible,
and confine himself to measures which if successful would improve
conditions rather than complicate them. My own judgment then is
that in any case where so formidable an operation would be
attempted by some, the best interests of the patient will be served
rather by simple colostomy.
Early operations upon cancer of the rectum afford comforting
prospects. It is not so much to the discredit of surgery as to the
discredit of the patient’s judgment, and of the carelessness of the
practitioners who first see these cases, that cancer of the rectum
has become such a bête noir and is justly regarded as so serious and
unpromising a measure.[60]
[60] It becomes a question of importance just when and where we
should cease to attempt operation on the colon from above or on the
sigmoid from below; in other words, the exact location of the tumor should
decide the measure when it can be accurately determined. Moreover, a
wide margin of bowel on either side of any new-growth which is about to
be resected should be excised. The question of blood supply to the margins
of the wound thus made is also of importance, as the most ideal operation
in appearance may be marred by gangrene due to lack of sufficient blood
supply. When there is sufficient uninvolved gut below the tumor to permit
of complete operation within the abdomen it is not advisable to do anything
from below; but there are some cases in which anything like complete
removal can only be effected by a combination of abdominal and sacral
routes. A thorough extirpation should be made above the growth as well as
of the involved tissue below. Those vessels which require ligation should be
tied accurately at the level of their division, and no ligation of trunks or
larger vessels should be attempted at any distance from the line of division.
If this be carefully carried out and the divided mesentery, with its ends, and
all the fat between the rectum and the sacrum be carefully dissected out,
there will rarely be difficulty in making an end-to-end reunion of the divided
bowel.
It is rarely necessary to include a colostomy with this procedure; in fact,
when a permanent opening has become necessary there is little possibility
of removing the main growth. Colostomy is a procedure for the hopeless
cases; resection is rarely to be thought of as an alternative. It should be an
early not a late measure, the reverse being true of colostomy, though even
this should not be too late.
Colostomy.—Colostomy for relief of rectal cancer is not a radical
operation, but in many cases is far more humane and satisfactory
than are those alluded to above. The intent is to make an opening in
the left side of the groin at a point where it is easily made. There are
two methods of performing colostomy here. One is to make an
opening through the abdominal wall, attach to it the presenting
surface of the sigmoid or colon, and either open it at once or some
hours later, when adhesions have cemented the desired union. Such
an opening may be made for emergency purposes under local
anesthesia, but when the colon is movable, and when the disease
has not yet involved the area thus exposed, or any portion above it,
a more desirable method is a deliberate one. An opening is made
such as is usually made on the right side when operating upon the
appendix. The bowel thus being accessible is divided between two
clamps, while the end of the lower segment is inverted and closed
with chromic or silk sutures, after which it is dropped back. This
leaves the upper portion with its open end corresponding to the
abdominal opening, into which it is fastened by a series of sutures,
being attached to the peritoneum and to the deep musculature
rather than to the skin, for if it be brought out too freely and
attached externally there is greater tendency to prolapse and
subsequent discomfort. Into the opening thus afforded a large-sized
rubber or bent glass tube is inserted for a few inches, around which
gauze is packed, and every effort is made to conduct fecal matter to
the exterior, as well to protect, at least for a few hours, the wound
itself from fecal contamination. Improvements in this technique have
been suggested, such as tying into the bowel a curved glass tube,
thus conducting its contents into a rubber bag or receptacle placed
outside the dressing. Another method which has been suggested by
Stewart is to connect the interior of the colon by a Murphy button
with a rubber bag or rubber dam upon the outside of the abdomen,
by which protection for this purpose can be afforded.
This operation makes a complete and final division of the colon,
and permanently excludes the rectum with its cancerous
involvement. It is not, therefore, in this respect, a radical measure.
The result, however, is that if the rectum be washed from below
each day it is kept far cleaner and freer from contact with irritative
foreign material than it otherwise would be. Furthermore, being
disused it tends to undergo to some degree a species of
physiological atrophy, and, in consequence, the cancer grows more
slowly, if there do not occur an apparent temporary cessation of
malignant activity.
By suitable management of the artificial anus, including the
deliberate emptying of the bowel every morning and the use of
protective pads for receptacles, it can be made far less disagreeable
than patients ordinarily fear (Figs. 595 and 596).

Fig. 595

Gleason’s pouch and supporter.


Fig. 596

Colostomy pad and bag, worn as is a truss. (Kelsey.)

The colostomy opening in the abdominal wall should be made as


small as practicable lest there occur not only more or less ventral
hernia through the weakened outlet, but even, as I have seen in one
case, a most extensive prolapse of the colon, in which two or three
years after performance of the operation the colon could be made to
prolapse to an extent of twelve or fifteen inches.
CHAPTER LI.
HERNIA.
The term hernia of itself implies protrusion or escape of a
contained organ or part through its containing walls, yet covered by
some of them. Thus we may have hernia of the iris, of the brain,
and the like; but when no particular part of the body is specified, by
common consent the term is understood as implying hernia either of
the intestine or the omentum, or of both. Such hernia may be either
of congenital or acquired character, the former condition being
permitted by some defect or abnormality in the abdominal parietes,
the latter being the immediate or remote result of accident or of
operation; and in the latter case they are referred to as traumatic or
as postoperative. Of these the former is usually of rapid and the
latter of slow development. Increased abdominal pressure doubtless
has much to do with the occurrence even of a truly congenital
hernia, as this would hardly develop were it not for the former. Such
pressure may be the result of occupation, of pregnancy, or of certain
morbid conditions—for example, those which cause constant
coughing or straining at stool, or straining during urination—as from
prostatic hypertrophy or phimosis, or such intra-abdominal
conditions as tumors, which distort the abdominal walls, or
accumulations of fluid which weaken them. Accident produces hernia
mainly by causing the effects of pressure to be manifested in a brief
space of time. Thus pressure or strain on abdominal muscles may
part them in such a way as to permit the immediate appearance of a
hernia, or its more slow development. The postoperative hernias are
usually of the so-called ventral type, and occur most often after
wounds which could not be immediately closed because of necessity
for drainage, or in those which were closed in such a way as to
permit of gradual warping or stretching of the resulting scar.
The surgical anatomy of hernia is described in works on anatomy.
It is necessary, therefore, here only to remind the reader that the
conditions existent in an old hernia may be different from those so
described, for the original anatomical outlines may perhaps have
long been lost and the original coverings more or less blended
together so as to become indistinguishable. Particularly is it true of
strangulated hernia that the more minute details are lost, and that in
such cases there is great difficulty in the effort to recognize distinct
anatomical layers and coverings. In old cases the sac—namely, the
original peritoneum—may be greatly thickened, while in strangulated
cases it will be discolored, perhaps even gangrenous, and will bear
but slight resemblance to the original condition. The same is true of
its contents, which may be adherent, strangulated, or gangrenous,
according to circumstances.
The opening through which the hernia appears is usually referred
to as the ring, to which, however, it may bear very little
resemblance. Thus it may be an elongated buttonhole-like, or a
warped, irregularly rounded sac opening, whose margins are thick or
thin and easily distinguished or otherwise.
By all writers hernias are classified according to their anatomical
characteristics as follows: Inguinal, indirect and direct; femoral,
umbilical, ventral, diaphragmatic, gluteal or ischiatic, obturator,
perineal, lumbar, sacrorectal, retroperitoneal (including the recently
described paraduodenal or Treitz variety), and properitoneal.
Of these the most common are the inguinal and the femoral, the
umbilical ranking next, while the other forms are rare.
Causes.—Regarding the cause and nature of the common forms
—namely, the inguinal and femoral—I propose here to introduce the
views enunciated by Russell, of Melbourne, which seem to me to
furnish the actual explanation for nearly all instances. This
explanation refers to the congenital origin of the condition, even
though it do not appear until the middle years of life. In the case of
inguinal hernia it refers also to the persistence of the canal of Nuck,
or of at least incomplete obliteration of the original vaginal process
or prolongation of the peritoneum, which comes down with the
migrating testicle and whose lower portion furnishes the cavity of
the tunica vaginalis. It is more rational to explain the occurrence of
hernia in connection with this preformed sac than by the view that
there are so many instances of congenital weakness of the
abdominal wall. That such weakness exists in many cases of hernia
is undeniable, but this is to be regarded as the effect rather than the
actual condition. From this last statement it follows also that there is
great advantage in early operation, and in complete removal of the
sac, which when performed early will not only cure the hernia but
prevent the weakening of the abdominal wall itself. It follows,
further, that the use of a truss, save possibly in the case of young
infants, is an improper method of treatment. In other words, upon it
is based the crux of the whole matter of successful treatment, i. e.,
operative removal of the sac.
It will be seen, then, that the cause of inguinal hernia is closely
related with the cause of so-called congenital hydrocele of the cord
(q. v.), the latter condition being one of sacculation of the canal,
with accumulation of fluid; and it is interesting to recall that such
sacculations are occasionally found in the ordinary so-called
congenital hernias, when they are seen early, and before all
anatomical surroundings have been merged together. The existence
of a hernia implies the presence of a sac, and a congenital defect
furnishes this latter, while the variations in the type of hernia are due
mainly to the variations in the sac itself, i. e., in its location.
Fig. 597 Fig. 598

Congenital hernia. Infantile hernia.

Russell has traced out the relations between the peritoneal


pouches of the lower abdomen and the principal bloodvessels, and
has shown how the former arrange themselves about the latter and
are carried with them as they develop, assuming in consequence the
type either of inguinal or femoral hernia, according as they are
placed to the inner or outer and lower side of the same. He has
insisted, and I think properly, that the variations observed in the
clinical manifestations of a hernia are mainly determined by the size
and the position of the sac, and that these depend upon its relations
to the femoral and epigastric vessels, the associated sac and vessel
being subject to the same vicissitudes in development. In this way
the occurrence at one time of a congenital and at another of a so-
called infantile type of inguinal hernia may be easily explained, as
well as the differences between the so-called funicular and the
partial form, and also the occurrence of the retroperitoneal or
properitoneal forms, which, as variations are rare, and as clinical
manifestations perplexing, but which nevertheless are easily
explained when viewed in this light (Figs. 597 and 598).
Fig. 599
Adhesions in hernial sac. Scarpa. (Lejars.)

Thus viewed, then, what are the relations of traumatism to


congenital defects? When thus explained they seem to be as follows:
By no means every individual who sustains an injury to the abdomen
suffers from hernia, but when the parts are already weakened or
prepared by the preëxistence of these congenital defects, then a
small amount of strain or injury may serve to open them up and to
produce a condition apparently due to accident which otherwise
could not have occurred. The more I have studied the entire
question the more I have come to the conclusion that hernias of the
ordinary type, save in case of extreme violence, would not occur
were it not for such a congenital prearrangement and tissue
permission, as it were; so that we are justified in assuming that
inguinal and femoral like umbilical hernias are really of congenital
origin.
The Signs of Hernia.—The signs of hernia include the existence
of a tumor, usually at one of the common outlets, which may be
variable in size, and fixed, changeable, or otherwise, according to
whether it consist of intestine or omentum. To a hernial protrusion
consisting of intestine alone may still be given the old term
enterocele. One consisting of omentum is known as epiplocele.
Hernial protrusions may attain tremendous dimensions, especially
those appearing at the umbilicus, and some of these sacs contain
perhaps the larger proportion of the intestine or even of the entire
abdominal contents. Scrotal tumors, again, may attain large size,
e. g., that of the individual’s head or even much larger. According to
the nature of the contents such a tumor will be more or less
resonant on percussion, and more or less compressible as well as
reducible. Reducibility—namely, the ability to be returned to the
abdominal cavity—is the most characteristic feature of a hernia and
one possessed by nearly every such tumor, at least at its inception.
It may, however, be lost.
Loss of reducibility, when occurring gradually, is replaced by what
is known as incarceration, i. e., more or less complete fixation, at
the same time without such pressure on bloodvessels as to produce
necrosis. Incarceration may be the result of reduction in caliber of
the hernial outlet, or of the formation of adhesions between the
walls of the sac and its contents, such adhesions being common
alike to omentum and large or small bowel. (See Fig. 599.)
Strangulation is an acute process which may terminate either a
reducible or an incarcerated hernia. It implies some sudden change,
such as overcrowding of the bowel within the sac, or some peculiar
kinking, by which intestinal caliber is shut off, as well as blood supply
affected because of pressure, by which the vitality of the gut and of
the sac is compromised or perhaps quickly lost. Strangulation, then,
includes at least the possibilities and usually the simultaneous
occurrence of acute obstruction of the bowel with more or less
gangrene of the sac itself, as well as of the compromised gut.
Reducibility as an ordinary feature of hernia is one with which the
patient himself is quite familiar, most patients with reducible hernias
being able to effect reduction in the horizontal position,
accompanied by some manipulation or maneuver. When in such
cases reduction cannot be accomplished incarceration or perhaps
strangulation has begun and the case immediately assumes serious
proportions. Reduction is usually accompanied by a peculiar gurgle,
as well as disappearance of the tumor itself, while the opening
through which it has disappeared can usually be identified with the
finger, by invagination of the scrotum, or by pressure over the
femoral region. Such a tumor usually reappears when the patient
stands, or particularly when he coughs or makes any straining effort,
and the occurrence and recurrence of these phenomena clearly
establish the diagnosis of hernia.
Irreducible or incarcerated hernias usually give some impulse upon
the patient’s coughing, as do the reducible forms, yet in some cases
they lead to more difficulty of diagnosis. Ordinarily in the male the
question is mainly as between inguinal (or scrotal) hernia and
hydrocele. In the latter there is a pear-shaped tumor whose apex
should be found below the level of the inguinal outlet; a tumor
which will fluctuate, whose shape does not change, which gives no
impulse when the patient coughs, which is not influenced by
pressure, even with the patient in the horizontal position. It is only in
incarcerated or in peculiar types of congenital hernias, or in those
combined, as they may be, with hydrocele, in which doubt should
not be easily dissipated. While incarceration predisposes to acute
obstruction it is not always followed by it, but may produce a more
chronic type of constipation, with tendency to fecal impaction,
because of the mechanical impediment to freedom of bowel motility.
This condition is more frequently met in the aged.
Inflammation of the hernial sac, as well as of its coverings, leads
to a condition described as inflamed hernia. It is essentially one of
circumscribed cellulitis. It may be due to the irritation of a badly
fitting truss or to other external causes. The inflammation may
extend so as to involve the sac wall itself, and thus produce
adhesions and later incarceration, or it may set up actual peritonitis,
which may extend to the general abdominal cavity and terminate
fatally. The more superficial and less acute forms are scarcely
distinguishable from a local erysipelas which may terminate by
abscess. Such a condition might be mistaken for one of suppurating
bubo. Nevertheless the existence of the hernia itself should guard
one against this error and make him extremely cautious in using the
knife, even though it be necessary for the evacuation of pus.
Strangulated hernia has already been considered as the most
common cause of acute obstruction of the bowel. Its possibility
should be excluded in every case of this serious condition. While
such are its general features, locally there is added to the general
bowel obstructive condition that of more or less local destruction,
which may vary from the presence of exudate, fluid or solid, with
infiltration of adjoining tissues, to the most prompt and disastrous
consequences of venous stasis, namely, extensive gangrene, which,
involving first the bowel itself or the omentum, will later spread to
the sac wall and its surroundings. In this instance around the loop or
loops of gut involved will be seen a tight constriction or sulcus,
above which the bowel will be more or less discolored and
distended, while below it will be completely necrotic and perhaps
actually sloughing. Minor degrees of strangulation may produce
conditions which would lead up to this, but have not yet actually
reached the stage of gangrene. Around such bowel will be found
Fig. 600
more or less fluid, the
result of transudation,
which will be
swarming with
bacteria and often
offensive. The sac
wall closely
corresponds in
appearance to that of
the bowel, and
everything about the
sac and its contents
will be infected and
contaminated with
bacteria, often of
most virulent activity.
The gangrene may
involve an area of
exceedingly small
size, or the entire
contents of the
hernial sac. In the
former instance the
condition is
Gangrenous strangulated hernia; artificial anus; comparatively simple
prolapse of bowel requiring intestinal resection; as compared with the
eventual recovery. (Preindlsberger.) latter, which may
require resection of
several feet of necrotic bowel. The proper treatment of these
conditions will be more fully dealt with below (Fig. 600).
Symptoms.—The symptoms of strangulation are those of acute
obstruction, plus the local evidences of a hernia, usually with added
pain and tenderness, sometimes acute. These symptoms may come
on as the result of strain or accident or without any known cause.
Their intensity will depend in some measure upon the completeness
of the blood stasis and the rapidity of the consequent gangrenous
process. The latter may vary in degree. Thus the death of the
compromised bowel may be practically determined within a few
hours or within two or three days. The hernial tumor, within which
strangulation has occurred, becomes more tense and
incompressible, and, at the same time, more tender. Sometimes
there is marked augmentation in volume; at other times this
changes but little. So soon as a loop of bowel has lost its blood
supply and become actually necrotic it will have also lost, when
exposed, all of its luster or “sheen,” and will appear not only black
and lusterless, but will be more or less offensive in odor, and of
extremely septic character. The surrounding fluid will be found
swarming with bacteria, and will seriously and perhaps fatally infect
anyone inoculated with it.
Concerning the color of the exposed bowel and its appearance, it
is a fairly safe rule to follow that gut which has not lost its luster,
even though darkly discolored, is still viable, and may with safety be
returned to the abdomen, which is probably the safest place for it;
but when its sheen is actually lost the case becomes one either for
resection or for artificial anus. It is possible that such a case may be
seen only after absolute necrosis and fecal escape have occurred.
When actual sloughing is thus met it is a question for resection or
some other expedient.
Varieties of Hernia. Inguinal Hernia.—The inguinal form of
hernia comprises nearly four-fifths of cases in males, a much smaller
proportion in females. The hernial protrusion is always through the
external abdominal ring, either by way of the inguinal canal, which it
enters through the internal ring, or directly through the abdominal
wall. The former is called indirect, the latter direct. Such a hernia is
considered complete or incomplete according as it descends below
the lower margin of the inguinal canal. An incomplete and direct
hernia is often referred to as bubonocele. (Fig. 601.)
Holding the views above enunciated, regarding the congenital
origin of practically every inguinal hernia, it is necessary to pay less
attention to the distinctions insisted upon by the earlier authors
concerning the congenital, the infantile, or the encysted forms of
hernia, which depend upon the extent and degree of closure of the
vaginal process or the canal of Nuck, which is carried down with the
testis during its migration from the lower margin of the Wolffian
body, and which is normally obliterated at birth. Nevertheless these
conditions, however explained, are actually met during life and are
represented by the diagrams seen in Figs. 602, 603 and 604.

Fig. 601

Indirect inguinal hernia (bubonocele.) (Richardson.)


Fig. 602 Fig. 603 Fig. 604

Congenital inguinal hernia. Infantile or encysted Hernia of the funicular


hernia. process.

In the female the canal of Nuck is a matter of minor importance,


containing only the round ligament. Nevertheless along it may
proceed an indirect inguinal hernia corresponding to that in the
male.
The so-called acquired indirect hernia, according to the above
views, would not occur were it not for the opportunity—as it were,
the temptation—already afforded by some deviation of the
peritoneal arrangement in this locality. In these cases, however, the
sac appears to be new and is pushed along the inguinal canal
anteriorly to its normal contents. This may be the result of violent
strain, or of one which is apparently disproportionately small, but
frequently repeated.
Direct inguinal hernia is generally an occurrence of adult life, takes
place commonly as the result of accident, is a direct protrusion
through the abdominal wall at the triangular weak spot, whose outer
limit is the deep epigastric artery, with the obliterated hypogastric
artery to the inner side and Poupart’s ligament below, i. e., the so-
called triangle of Hesselbach. This hernia appears always at the
external ring, from which it may descend and become scrotal.
Fig. 605

Scrotal hernia. (Richardson.)


With complete or scrotal hernia there is usually little difficulty of
diagnosis (Fig. 605). An incomplete hernia, protruding at the
external ring, covered with considerable fat, and perhaps shifted a
little in position, is sometimes hard to distinguish from a hernia
through the femoral opening. The inguinal form escapes above
Poupart’s ligament, the femoral always below it, and Poupart’s
ligament is to be located by a line drawn from the anterior superior
spine to the spine of the pubis. The inguinal forms are usually nearer
the middle line. If the epigastric artery can be identified, either
before or during operation, the character of the hernia will be
promptly demonstrated by its relations to the neck of the sac.
Hernial protrusions give a familiar impulse on coughing unless the
incarceration of an epiplocele may mask this feature. By it they are
to be distinguished from hydrocele, varicocele, aneurysm,
undescended testicle, and the like.

Fig. 606

Hernia of liver through congenital opening in the umbilicus. (Richardson.)

Femoral Hernia.—Femoral hernia is much more common in women


than in men, and constitutes about one-tenth of all cases. This form
is also nearly always congenital in the above sense, and is
particularly liable to strangulation. It escapes through the femoral

You might also like