0% found this document useful (0 votes)
7 views48 pages

Introduction to Programming with Java 3rd Edition John Dean download

The document is a comprehensive guide to programming using Java, authored by John Dean and Raymond Dean, and published by McGraw Hill LLC. It covers fundamental concepts such as algorithms, object-oriented programming, and exception handling, along with practical examples and exercises. The third edition includes updates and enhancements to reflect current programming practices and technologies.

Uploaded by

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

Introduction to Programming with Java 3rd Edition John Dean download

The document is a comprehensive guide to programming using Java, authored by John Dean and Raymond Dean, and published by McGraw Hill LLC. It covers fundamental concepts such as algorithms, object-oriented programming, and exception handling, along with practical examples and exercises. The third edition includes updates and enhancements to reflect current programming practices and technologies.

Uploaded by

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

Introduction to Programming with Java 3rd Edition

John Dean download pdf

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

Visit ebookultra.com today to download the complete set of


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

Introduction to Programming with Greenfoot Object Oriented


Programming in Java with Games and Simulations 1st Edition
Michael Kolling
https://ebookultra.com/download/introduction-to-programming-with-
greenfoot-object-oriented-programming-in-java-with-games-and-
simulations-1st-edition-michael-kolling/

Introduction to Java Programming Brief 8th Edition Edition


Y. Daniel Liang

https://ebookultra.com/download/introduction-to-java-programming-
brief-8th-edition-edition-y-daniel-liang/

Chaudhary Introduction to Java Programming Advanced


Features Core Series Updated To Java 8 2nd Edition Harry
H.
https://ebookultra.com/download/chaudhary-introduction-to-java-
programming-advanced-features-core-series-updated-to-java-8-2nd-
edition-harry-h/

Introduction to Neural Networks with Java 2nd Edition Jeff


Heaton

https://ebookultra.com/download/introduction-to-neural-networks-with-
java-2nd-edition-jeff-heaton/
Beginning Programming with Python For Dummies 3rd Edition
John Paul Mueller

https://ebookultra.com/download/beginning-programming-with-python-for-
dummies-3rd-edition-john-paul-mueller/

Practical Database Programming with Java 1st Edition Ying


Bai

https://ebookultra.com/download/practical-database-programming-with-
java-1st-edition-ying-bai/

Dean Dyer Introduction to Intellectual Property Law 1st


Edition Owen Dean

https://ebookultra.com/download/dean-dyer-introduction-to-
intellectual-property-law-1st-edition-owen-dean/

Python Programming An Introduction to Computer Science


John M. Zelle

https://ebookultra.com/download/python-programming-an-introduction-to-
computer-science-john-m-zelle/

Beginning Programming with Java For Dummies 4th Edition


Barry Burd

https://ebookultra.com/download/beginning-programming-with-java-for-
dummies-4th-edition-barry-burd/
Introduction to Programming with Java 3rd Edition John
Dean Digital Instant Download
Author(s): John Dean, Ray Dean
ISBN(s): 9781259875762, 1259875768
Edition: 3
File Details: PDF, 92.85 MB
Year: 2020
Language: english
Page i

John Dean
Park University

Raymond Dean
University of Kansas
Page ii

INTRODUCTION TO PROGRAMMING WITH JAVA

Published by McGraw Hill LLC, 1325 Avenue of the Americas, New York, NY 10121.
Copyright ©2021 by McGraw Hill LLC. All rights reserved. Printed in the United States of
America. No part of this publication may be reproduced or distributed in any form or by any
means, or stored in a database or retrieval system, without the prior written consent of
McGraw Hill LLC, including, but not limited to, in any network or other electronic storage or
transmission, or broadcast for distance learning.

Some ancillaries, including electronic and print components, may not be available to
customers outside the United States.

This book is printed on acid-free paper.

1 2 3 4 5 6 7 8 9 LCR 24 23 22 21 20

ISBN 978-1-26057524-8
MHID 1-260-57524-1

Cover Image: ©Shutterstock/Brian Lasenby

All credits appearing on page or at the end of the book are considered to be an extension of
the copyright page.

The Internet addresses listed in the text were accurate at the time of publication. The
inclusion of a website does not indicate an endorsement by the authors or McGraw Hill LLC,
and McGraw Hill LLC does not guarantee the accuracy of the information presented at these
sites.

mheducation.com/highered
Page iii
edication
—To Stan and Kate
Page iv

About the Authors

John Dean is an Associate Professor in the Computer Science and Information Systems
Department at Park University. He earned a Ph.D. degree in computer science from Nova
Southeastern University and an M.S. degree in computer science from the University of
Kansas. He is Java certified and has worked in industry as a software engineer and project
manager, specializing in Java and various web technologies—JavaScript, JavaServer Pages,
and servlets. He has taught a full range of computer science courses, including Java
programming and Java-based web programming. He has authored a web programming
textbook with a focus on client-side technologies HTML5, CSS, and JavaScript.

Raymond Dean is a Professor Emeritus, Electrical Engineering and Computer Science,


University of Kansas. He earned an M.S. degree from MIT and a Ph.D. degree from
Princeton University. As a professional engineer in the HVAC industry, he wrote computer
programs that design air distribution systems and analyze energy consumption and sound
propagation in buildings. At the University of Kansas, he taught microprocessor
programming, data structures, and other courses in electrical engineering and computer
science.
Page v

Contents
Preface x
Project Summary xxiv

CHAPTER 1

Introduction to Computers and Programming 1


1.1 Introduction 2
1.2 Hardware Terminology 2
1.3 Program Development 10
1.4 Source Code 12
1.5 Compiling Source Code into Object Code 13
1.6 Portability 14
1.7 Emergence of Java 15
1.8 Computer Ethics 18
1.9 First Program—Hello World 19
1.10 GUI Track: Hello World (Optional) 24

CHAPTER 2
Algorithms and Design 32
2.1 Introduction 32
2.2 Output 33
2.3 Variables 34
2.4 Operators and Assignment Statements 35
2.5 Input 36
2.6 Flow of Control and Flowcharts 37
2.7 if Statements 38
2.8 Loops 43
2.9 Loop Termination Techniques 45
2.10 Nested Looping 48
2.11 Tracing 51
2.12 Problem Solving: Other Pseudocode Formats and an Asset Management
Example 55

CHAPTER 3

Java Basics 65
3.1 Introduction 66
3.2 “I Have a Dream” Program 66
3.3 Comments and Readability 67
3.4 The Class Heading 69
3.5 The main Method’s Heading 69
3.6 Braces 70
3.7 System.out.println 71
3.8 Compilation and Execution 73
3.9 Identifiers 73
3.10 Variables 74
3.11 Assignment Statements 75
3.12 Initialization Statements 77
3.13 Numeric Data Types—int, long, float, double 78
3.14 Constants 80
3.15 Arithmetic Operators 83
3.16 Expression Evaluation and Operator Precedence 86
3.17 More Operators: Increment, Decrement, and Compound Assignment 88
3.18 Tracing 90
3.19 Type Casting 90
3.20 char Type and Escape Sequences 93
3.21 Primitive Variables Versus Reference Variables 95
3.22 Strings 96
3.23 Input—the Scanner Class 100
3.24 Simple File Input for Repetitive Testing During Program Development 105
3.25 GUI Track: Input and Output with Dialog Boxes (Optional) 107
CHAPTER 4

Control Statements 119


4.1 Introduction 120 Page vi
4.2 Conditions and Boolean Values 120
4.3 if Statements 121
4.4 && Logical Operator 124
4.5 | | Logical Operator 129
4.6 ! Logical Operator 131
4.7 Switching Constructs 132
4.8 while Loop 138
4.9 do Loop 142
4.10 for Loop 144
4.11 Solving the Problem of Which Loop to Use 149
4.12 Nested Loops 150
4.13 boolean Variables 152
4.14 Input Validation 156
4.15 Problem Solving with Boolean Logic (Optional) 157

CHAPTER 5
Using Prebuilt Methods 170
5.1 Introduction 170
5.2 The API Library 171
5.3 Math Class 177
5.4 Wrapper Classes for Primitive Types 182
5.5 Character Class 186
5.6 String Methods 188
5.7 Formatted Output with the printf> Method 194
5.8 Problem Solving with Random Numbers (Optional) 199
5.9 GUI Track: Covering an Image with a Tinted Pane (Optional) 203

Interlude 213
Multiple-Method Programs in a Non-Object-Oriented Environment 213
GUI Track: Multiple-Method Program That Uses StackPane and Group to
Display Images, Rectangles, Lines, an Oval, and Text (Optional) 216

CHAPTER 6

Object-Oriented Programming 222


6.1 Introduction 223
6.2 Object-Oriented Programming Overview 223
6.3 First OOP Class 227
6.4 Driver Class 230
6.5 Calling Object, this Reference 234
6.6 Instance Variables 236
6.7 Tracing an OOP Program 237
6.8 UML Class Diagrams 242
6.9 Local Variables 244
6.10 The return Statement 247
6.11 Argument Passing 249
6.12 Specialized Methods—Accessors, Mutators, and Boolean Methods 252
6.13 Problem Solving with Simulation (Optional) 255

CHAPTER 7

Object-Oriented Programming— Additional Details 272


7.1 Introduction 273
7.2 Object Creation—A Detailed Analysis 273
7.3 Assigning a Reference 275
7.4 Testing Objects for Equality 279
7.5 Passing References as Arguments 284
7.6 Method-Call Chaining 286
7.7 Overloaded Methods 289
7.8 Constructors 293
7.9 Overloaded Constructors 299
7.10 Static Variables 303
7.11 Static Methods 306
7.12 Named Constants 312
7.13 Problem Solving with Multiple Driven Classes 314

CHAPTER 8

Software Engineering 324


8.1 Introduction 325
8.2 Coding-Style Conventions 325
8.3 Documentation for Outsiders 334
8.4 Helper Methods 338
8.5 Encapsulation (with Instance Variables and Local Variables) 342 Page vii
8.6 Recognizing the User’s Point of View 344
8.7 Design Philosophy 345
8.8 Top-Down Design 350
8.9 Bottom-Up Design 359
8.10 Case-Based Design 361
8.11 Iterative Enhancement 361
8.12 Merging the Driver Method into the Driven Class 363
8.13 Accessing Instance Variables Without Using this 365
8.14 Writing Your Own Utility Class 366
8.15 Problem Solving with the API Calendar Class (Optional) 368
8.16 GUI Track: Problem Solving with CRC Cards (Optional) 370

CHAPTER 9

Arrays 384
9.1 Introduction 385
9.2 Array Basics 385
9.3 Array Declaration and Creation 387
9.4 Array length Property and Partially Filled Arrays 391
9.5 Copying an Array 393
9.6 Problem Solving with Array Case Studies 397
9.7 Searching an Array 403
9.8 Sorting an Array 408
9.9 Two-Dimensional Arrays 412
9.10 Arrays of Objects 418
9.11 For-Each Loops 425

CHAPTER 10

ArrayLists and an Introduction to the Java Collections Framework 435


10.1 Introduction 436
10.2 The ArrayList Class 437
10.3 Storing Primitives in an ArrayList 443
10.4 ArrayList Example Using Anonymous Objects and the For-Each Loop 446
10.5 ArrayLists Versus Standard Arrays 450
10.6 The LinkedList Class 451
10.7 The List Interface 452
10.8 Problem Solving: How to Compare Method Execution Times 453
10.9 Queues, Stacks, and the ArrayDeque Class 457
10.10 Overview of the Java Collections Framework 464
10.11 Collections Example—Information Flow in a Network of Friends 468
10.12 GUI Track: Second Iteration of Problem Solving with CRC Cards (Optional)
476

CHAPTER 11
Recursion 489
11.1 Introduction 490
11.2 Guidelines for Writing a Recursive Method 491
11.3 A Recursive Factorial Method 492
11.4 Comparison of Recursive and Iterative Solutions 496
11.5 Recursive Method Evaluation Practice 500
11.6 Binary Search 503
11.7 Merge Sort 506
11.8 Towers of Hanoi 510
11.9 Problem Solving with Performance Analysis 514
11.10 GUI Track: Drawing Trees with a Fractal Algorithm (Optional) 517

CHAPTER 12
Type Details and Alternative Coding Mechanisms 530
12.1 Introduction 531
12.2 Integer Types and Floating-Point Types 532
12.3 char Type and the ASCII Character Set 536
12.4 Type Conversions 538
12.5 Prefix/Postfix Modes for Increment/ Decrement Operators 541
12.6 Embedded Assignments 544
12.7 Conditional Operator Expressions 546
12.8 Expression Evaluation Review 547
12.9 Short-Circuit Evaluation 551
12.10 Empty Statement 552
12.11 Using break to Exit from a Loop 554 Page viii
12.12 for Loop Header Details 555
12.13 Enumerated Types 557
12.14 forEach Method, Lambda Expressions, Method References, and Streams 564
12.15 Hexadecimal, Octal, and Binary Numbers 573
12.16 GUI Track: Unicode (Optional) 574
12.17 Introduction to GridWorld Case Study (Optional) 579

CHAPTER 13

Aggregation, Composition, and Inheritance 591


13.1 Introduction 592
13.2 Composition and Aggregation 592
13.3 Inheritance Overview 599
13.4 Implementation of a Person/Employee/FullTime Hierarchy 603
13.5 Constructors in a Subclass 605
13.6 Method Overriding 606
13.7 Using the Person/Employee/FullTime Hierarchy 609
13.8 The final Access Modifier 610
13.9 Using Inheritance with Aggregation and Composition 610
13.10 Design Practice with Card Game Example 613
13.11 GridWorld Case Study Extensions (Optional) 619
13.12 Problem Solving with Association Classes (Optional) 626
CHAPTER 14

Inheritance and Polymorphism 637


14.1 Introduction 638
14.2 The Object Class and Automatic Type Promotion 638
14.3 The equals Method 639
14.4 The toString Method 643
14.5 Polymorphism and Dynamic Binding 648
14.6 Assignments When the Two Sides’ Classes Are Different 653
14.7 Polymorphism with Arrays 654
14.8 abstract Methods and Classes 660
14.9 Interfaces 663
14.10 The protected Access Modifier 673
14.11 GUI Track: Three-Dimensional Graphics (Optional) 677

CHAPTER 15

Exception Handling 691


15.1 Introduction 692
15.2 Overview of Exceptions and Exception Messages 692
15.3 Using try and catch Blocks to Handle “Dangerous” Method Calls 693
15.4 Line Plot Example 695
15.5 try Block Details 699
15.6 Two Categories of Exceptions—Checked and Unchecked 700
15.7 Unchecked Exceptions 702
15.8 Checked Exceptions 705
15.9 Generic catch Block with Exception Class 708
15.10 Multiple catch Blocks and Multiple Exceptions per Block 712
15.11 Understanding Exception Messages 714
15.12 Using a throws Clause to Postpone the catch 718
15.13 Automatic Cleanup Using Try-With-Resources 720
15.14 GUI Track: Line Plot Example Revisited (Optional) 722

CHAPTER 16
Files, Buffers, Channels, and Paths 735
16.1 Introduction 736
16.2 Simple Text-File Example: HTML File Generator 737
16.3 A Website Reader 741
16.4 Object File I/O 743
16.5 Character Sets and File-Access Options 748
16.6 Buffered Text File I/O 749
16.7 Primitive Buffers with Random Access 752
16.8 Channel I/O and Memory-Mapped Files 760
16.9 Path, Whole-File, and Directory Operations 767
16.10 Walking a Directory Tree 769 Page ix
16.11 GUI Track: Final Iteration of Problem Solving with CRC Cards (Optional) 775

CHAPTER 17

GUI Programming Basics 787


17.1 Introduction 788
17.2 SimpleWindow Program 791
17.3 Stage and Scene 794
17.4 JavaFX Components 796
17.5 Label Control 797
17.6 TextField Control 799
17.7 Greeting Program 801
17.8 Event Handling 805
17.9 Property Binding 809
17.10 JavaFX CSS 812
17.11 Scene Graph Inheritance 818
17.12 Style Sheets and Cascading 821
17.13 Button Control and FactorialButton Program 826
17.14 Distinguishing Between Multiple Events 832
17.15 Colors 834
17.16 ColorChooser Program 838

CHAPTER 18
GUI Programming—Layout Panes 849
18.1 Introduction 849
18.2 Layout Panes 851
18.3 FlowPane and GridPane—Competing Layout Philosophies 853
18.4 VBox Program with Two Stages and an Image File 858
18.5 BorderPane 867
18.6 TilePane and TextFlow Containers 872
18.7 TicTacToe Program 878
18.8 Embedded Panes, HBox, and MathCalculator Program 882
18.9 Plain Pane Container and Component Positioning 889

CHAPTER 19

GUI Programming—Additional GUI Components, Additional Event


Handlers, Animation 896
19.1 Introduction 897
19.2 User Interface Design 897
19.3 TextArea Control 898
19.4 CheckBox and RadioButton Controls 903
19.5 ComboBox Control 909
19.6 Job Application Program 913
19.7 ScrollPane and Menu Classes 918
19.8 Images and Mouse Events 922
19.9 Lunar Eclipse Program with Circle, RadialGradient, and Slider 928
19.10 Animation 933

Appendices
Appendix 1 ASCII Character Set 943
Appendix 2 Operator Precedence 945
Appendix 3 Java Keywords and Other Reserved Words 947
Appendix 4 Packages and Modules 951
Appendix 5 Java Coding-Style Conventions 963
Appendix 6 Javadoc with Tags 975
Appendix 7 UML Diagrams 980
Appendix 8 Number Systems and Conversions Between Them 986
Additional Online Material
Chapter S6 Writing Methods in a Non-Object-Oriented Environment
Chapter S9 Arrays in a Non-Object-Oriented Environment
Chapter S17 GUI Programming Basics (with Swing and AWT)
Chapter S18 GUI Programming—Component Layout, Additional GUI
Components (with Swing and AWT)
Appendix 9 Multithreading

Index 990
Page x

Preface
In this book, we lead you on a journey into the fun and exciting world of computer
programming. Throughout your journey, we’ll provide you with lots of problem-solving
practice. After all, good programmers need to be good problem solvers. We’ll show you how
to implement your problem solutions with Java programs. We provide a plethora of
examples, some short and focused on a single concept, some longer and more “real world.”
We present the material in a conversational, easy-to-follow manner aimed at making your
journey a pleasant one. When you’re done with the book, you should be a proficient Java
programmer.
Our textbook targets a wide range of readers. Primarily, it targets students in a standard
college-level “Introduction to Programming” course or course sequence where no
prerequisite programming experience is assumed. We have included the topics recommended
by the College Board for high school students studying for advanced placement (AP) in
computer science. So this text should be good for those students as well.
In addition to targeting students with no prerequisite programming experience, our
textbook targets industry practitioners and college-level students who have some
programming experience and want to learn Java. This second set of readers can skip the early
chapters on general programming concepts and focus on the features of Java that differ from
the languages that they already know. In particular, because C++ and Java are similar, readers
with a C++ background should be able to cover the textbook in a single three-credit-hour
course. (But we should reiterate for those of you with no programming experience:
No prerequisite programming experience is required in order to use this text.)
Finally, our textbook targets those who are learning Java on their own, outside of a
classroom environment. This third set of readers should read the entire textbook at a pace
determined on a case-by-case basis.

What’s New in This Edition?

The changes in this edition are big and small. Big changes include new chapters, reorganized
chapter sections, new programming constructs, new program examples, and new exercises.
Smaller changes include updating explanations and anecdotes. We’ve combed the entire book
for opportunities to improve the book’s clarity and readability. The following list highlights
the more significant changes that we’ve made to this edition.
• Introductory Chapter
To keep up with the computer industry’s growth, we’ve made quite a few changes to
Chapter 1, such as updating the information in the computer hardware and Java history
sections.
• Switching Constructs
Java 12 and Java 13 made improvements to the venerable switch statement, and this
edition describes those improvements. We use the new switching techniques (multiple
comma-​separated case constants and no break statements) for programs throughout the
book. And we use switch statements versus switch expressions according to what the
problem calls for. If you’re a fan of the old-style switch statement, no worries, we
provide a description early on which will help you with legacy code.
• Local Variable Type Inferencing
Java 10 introduced the ability to use var as a type (rather than int, double, etc.) for a
local variable declaration where the declaration is part of an initialization. We describe
the new syntax, but for self-documentation reasons, we stick with traditional explicit
type declarations for the most part.
• Name Change for Static Variables and Static Methods Page xi

The powers that be (the Oracle documentation folks) now use the terms static variable
and static method for what used to be known as class variable and class method, so
we’ve updated accordingly.
• Miscellaneous Java API Library Updates
With the new Java releases since the second edition, there have been quite a few updates
to the Java API library. We’ve updated our discussions and programs with new API
method and constructor calls when appropriate. Most of our new API content can be
found in our GUI coverage, but there are other API changes sprinkled throughout the
book. For example, with Java’s deprecation of the wrapper class constructors, we’ve
refactored our programs to rely on the wrapper classes’ valueOf methods.
• New Section—forEach Method and Streams
We introduce the forEach method as a simple alternative to the for-each loop in the
context of an ArrayList. We then use the forEach method in the context of streams,
where it really shines. We describe streams in depth, with their exciting potential to take
advantage of parallel processing to improve a program’s efficiency.
• Lambda Expressions and Method References
Lambda expressions and method references are techniques that allow you to implement
the functionality of a method so you can use it as an argument in a method call. We first
present lambda expressions and method references as arguments for a forEach method
call. Later, we use lambda expressions and method references extensively to help with
the GUI programs.
• Interfaces with Static Methods and Default Methods
We’ve rewritten Chapter 14’s section on interfaces to include a discussion of static
methods and default methods. Oracle added them to interfaces because they support an
interface’s ability to implement multiple inheritance effectively.
• End-of-Chapter GUI Sections
We’ve rewritten all of our end-of-chapter GUI sections to take advantage of Java’s
newer GUI constructs.
• Three New Chapters—JavaFX
In this book’s second edition, we used the AWT and Swing platforms for our two GUI
chapters. This third edition moves those chapters to the book’s website. We provide
three new chapters in the main body of the book that describe GUI programming using
the JavaFX platform. As part of that presentation, you’ll learn how to format your
programs using JavaFX CSS properties.
• New Appendix—Modules
In Appendix 4, we introduce modules, which allow you to group together packages.
Modules make it easier to organize and share classes for different programming needs.
They are used to facilitate the configuration of Java software for diverse hardware and
software platforms.
• New Exercises
We have substantially changed most of the exercises and altered almost all of them in
some way. As before, we provide exercise solutions on the password-protected
instructor’s portion of the book’s website.
Page xii

Compliant with the College Board’s AP Computer


Science A Curriculum
We have put a great deal of effort into ensuring that this textbook is compliant with the
College Board’s Advanced Placement (AP) Computer Science A curriculum content. It
follows all the AP Computer Science A guidelines. As such, it appears on the College
Board’s approved textbook list at https://apcentral.collegeboard.org/courses/ap-computer-
science-a/course-audit.

Textbook Cornerstone #1: Problem Solving


Being able to solve problems is a critical skill that all programmers must possess. We teach
programmatic problem solving by emphasizing two of its key elements—algorithm
development and program design.
Emphasis on Algorithm Development
In Chapter 2, we immerse readers into algorithm development by using pseudocode for the
algorithm examples instead of Java. In using pseudocode, students are able to work through
nontrivial problems on their own without getting bogged down in Java syntax—no need to
worry about class headings, semicolons, braces, and so on.1 Working through nontrivial
problems enables students to gain an early appreciation for creativity, logic, and organization.
Without that appreciation, Java students tend to learn Java syntax with a rote-memory
attitude. But with that appreciation, students tend to learn Java syntax more quickly and
effectively because they have a motivational basis for learning it. In addition, they are able to
handle nontrivial Java homework assignments fairly early because they have prior experience
with similarly nontrivial pseudocode homework assignments.
In Chapter 3 and in later chapters, we rely primarily on Java for algorithm-development
examples. But for the more involved problems, we sometimes use high-level pseudocode to
describe first-cut proposed solutions. Using pseudocode enables readers to bypass syntax
details and focus on the algorithm portion of the solution.

Emphasis on Program Design


Problem solving is more than just developing an algorithm. It also involves figuring out the
best implementation for the algorithm. That’s program design. Program design is extremely
important, and that’s why we spend so much time on it. Frequently, we explain the thought
processes that a person might go through when coming up with a solution. For example, we
explain how to choose between different loop types, how to split up a method into multiple
methods, how to decide on appropriate classes, how to choose between instance and static
members, and how to determine class relationships using inheritance and composition. We
challenge students to find the most elegant implementations for a particular task.
We devote a whole chapter to program design—Chapter 8, “Software Page xiii
Engineering.” In that chapter, we provide an in-depth look at coding-style
conventions and documentation for programmers and users. We discuss design strategies like
separation of concerns, modularization, and encapsulation. Also in the chapter, we describe
alternative design strategies—top-down, bottom-up, case-based, and iterative enhancement.

Problem-Solving Sections
We often address problem solving (algorithm development and program design) in the
natural flow of explaining concepts. But we also cover problem solving in sections that are
wholly devoted to it. In each problem-solving section, we present a situation that contains an
unresolved problem. In coming up with a solution for the problem, we try to mimic the real-
world problem-solving experience by using an iterative design strategy. We present a first-cut
solution, analyze the solution, and then discuss possible improvements to it. We use a
conversational trial-and-error format (e.g., “What type of layout manager should we use? We
first tried the GridLayout manager. That works OK, but not great. Let’s now try the
BorderLayout manager.”). This casual tone sets the student at ease by conveying the message
Random documents with unrelated
content Scribd suggests to you:
Stuart, D., I. 406, 427

Stumpf. C, on attention, I. 426;


on difference, 493;
on fusion of impressions, 522, 530-3;
on strong and weak sensations, 547;
on relativity of knowledge, II. 11;
on sensations of extent, 219, 221

Subjective sensations, I. 516 ff.

Substance, spiritual, I. 345

Substantive states of mind, I. 243

Substitution of parts for wholes in reasoning, II. 330;


of the same for the same, 650

Subsumption, the principle of mediate, II. 648

Succession, not known by successive feelings, I. 628;


vs. duration, 609

Suggestion, in hypnotism, II. 598-601;


post-hypnotic, 613

Suicide, I. 317

Sully, J., I. 191; II. 79, 221, 272, 281, 322, 425

Summation of stimuli, I. 82;


of elements of feeling, 151;
the latter is inadmissible, 158

Superposition, in space-measurements, II. 177, 266 ff.


Symbols as substitutes for reality, II. 305

Sympathy, II. 410

Synthetic judgments a priori, II. 661-2

Systems, philosophic, sentimental, and mechanical, II. 665-7

Tactile centre, I. 58

Tactile images, II. 65

Tactile sensibility, its cortical centre, I. 34, 61, 62

Taine, H., on unity of self, I. 355;


on alterations of ditto, 376;
on recollecting, 658, 670;
On projection of sensations, II. 33;
on images, 48, and their 'reduction,' 125-6;
on reality, 291

Tàkacs, II. 490

Tarde, G., I. 263

Taylor, C. F., II. 99

Tedium, I. 626

Teleology, created by consciousness, I. 140-1;


essence of intelligence, 482
involved in the fact of essences, II. 335;
its barrenness in the natural sciences, 665
Tendency, feelings of, I. 250-4

Thackeray, W. M., II. 434

Thermometry, cerebral, I. 99

'Thing,' II. 184, 259

Thinking, the consciousness of, I. 300 ff.

Thinking principle, I. 342

Third dimension of space, II. 134 ff., 212 ff., 220

Thompson, D. G., I. 354; II. 662

Thomson, Allen, I. 84

Thought, synonym for consciousness at large, I. 186;


the stream of, Chapter IX:
it tends to personal form, 225;
same thought never comes twice, 231 ff.;
sense in which it is continuous, 237;
can be carried on in any terms, 260-8;
what constitutes its rational character, 269;
is cognitive, 271;
not made up of parts, 276 ff., II. 79 ff.;
always partial to some of its objects, I. 284 ff.;
the consciousness of it as a process, 300 ff.;
the present thought is the thinker, 369, 401;
depends on material conditions, 553

'Thought reading,' II. 525

Time, occupied by neural and mental processes, see reaction-time


Time, unconscious registration of, I. 201

Time, the perception of, Chapter XV;


begins with duration, I. 609;
compared with perception of space, 610 ff.;
empty time not perceived, 619;
its discrete flow, 621, 637;
long intervals conceived symbolically, 622 ff.;
variations in our estimate of its length, 623 ff.;
cerebral process underlying, 627 ff.

Tischer, I. 524, 527

Touch, cortical centre for, I. 58

Trance, see hypnotism

Transcendentalist theory of the Self, I. 342, 360 ff.;


criticised, 363 ff.

Transitive states of mind, I. 243 ff.

Tschisch, von, I. 414, 560

Tuke, D. H., II. 130, 413

Taylor, E. B., II. 304

Tympanic membrane, its tactile sensibility, II. 140

Tyndall, I. 147-8

Ueberweg, I. 187

Unconscious states of Mind, proofs of their existence, I. 164 ff.;


Objections, 164 ff.

Unconsciousness, I. 199 ff.;


in hysterics, 202 ff.;
of useless sensations, 517 ff.

Understanding of a sentence, I. 281

Units, psychic, I. 151

Unity of original object, I. 487-8; II. 8, 183 ff.

Universal conceptions, I. 473. See general propositions

Unreality, the feeling of, II. 298

Valentin, I. 557

Varying concomitants, law of dissociation by, I. 506

Vennum, Lurancy, I. 397

Ventriloquism, II. 184

Verdon, R., I. 685

Vertigo, II. 89;


Mental vertigo, 309;
optical, 506

Vicarious function of brain-parts, I. 69, 142; II. 592

Vierordt, I. 616 ff.; II. 154, 172

Vintschgau, I. 95-6
Vision with head upside down, II. 213

Visual centre in brain, I. 41 ff.

Visual space, II. 211 ff.

Visualizing power, II. 51-60

Vocalization, II. 407

Volition, see Will

Volkmann. A. W., II. 198, 252 ff.

Volkmann, W. von Volkmar, I. 627, 629, 631; II. 276

Voluminousness, primitive, of sensations, II. 184

Voluntary thinking, I. 583

Vulgarity of mind, II. 370

Vulpian, I. 73

Wahle, I. 493

Waitz, Th., I. 405, 632; II. 436

Walking, in child, II. 405

Walter. J. E., I. 214

Ward, J., I. 162, 454, 548, 562, 629, 633; II. 282
Warren, J. W., I. 97

Wayland, I. 347

Weber, E. H., his 'law,' I. 537 ff.


On space-perception on skin, II. 141-2;
on muscular feeling, 198

Weed, T., I. 665

Weissmann, A., II. 684 ff.

Wernicke's convolution, I. 39, 54-5

'Wheatstone's experiment,' II. 326-7

Wigan, Dr., I. 390, 675; II. 566-7

Wilbrand, I. 50-1

Will, Chapter XXVI;


involves memory of past acts, and nothing else but consent that
they shall occur again, II. 487-518;
the memory may involve images of either resident or remote
effects of the movement, 518-22;
ideo-motor action, 522-8;
action after deliberation, 528;
decision, 531;
effort, 535;
the explosive will, 537;
the obstructed will, 546;
relation of will to pleasure and pain, 549 ff.;
to attention, 561;
terminates in an 'idea', 567;
the question of its indeterminism, 569;
psychology must assume determinism, 576;
neural processes concerned in education of the will, 579 ff.

Will, relations of, to Belief, II. 320

Wills, Jas., I. 241

Witchcraft, II. 309

Wolfe, H. K., I. 674, 679

Wolff, Chr., I. 409, 651

World, the peculiar constitution of the, II. 337, 647, 651-2

Writing, automatic, I. 393 ff.

Wundt, on frontal lobes, I. 64;


on reaction-time, 89-94, 96, 427 ff., 525;
on introspective method, 189;
on self-consciousness, 303;
on perception of strokes of sound, 407;
on perception of simultaneous events, 411 ff.;
on Weber's law, 534 ff.;
association-time, 557, 560;
on time-perception, 608, 612 ff., 620, 634.
on local signs, II. 155-7;
on eyeball-muscles, 200;
on sensations, 219;
on paresis of ext. rectus, 236;
on contrast, 250;
on certain illusions, 264;
on feeling of innervation, 266, 493;
on space as synthesis, 276;
on emotions, 481;
on dichotomic form of thought, 654
Zöllner's pattern, II. 232
*** END OF THE PROJECT GUTENBERG EBOOK THE PRINCIPLES
OF PSYCHOLOGY, VOLUME 1 (OF 2) ***

Updated editions will replace the previous one—the old editions


will be renamed.

Creating the works from print editions not protected by U.S.


copyright law means that no one owns a United States
copyright in these works, so the Foundation (and you!) can copy
and distribute it in the United States without permission and
without paying copyright royalties. Special rules, set forth in the
General Terms of Use part of this license, apply to copying and
distributing Project Gutenberg™ electronic works to protect the
PROJECT GUTENBERG™ concept and trademark. Project
Gutenberg is a registered trademark, and may not be used if
you charge for an eBook, except by following the terms of the
trademark license, including paying royalties for use of the
Project Gutenberg trademark. If you do not charge anything for
copies of this eBook, complying with the trademark license is
very easy. You may use this eBook for nearly any purpose such
as creation of derivative works, reports, performances and
research. Project Gutenberg eBooks may be modified and
printed and given away—you may do practically ANYTHING in
the United States with eBooks not protected by U.S. copyright
law. Redistribution is subject to the trademark license, especially
commercial redistribution.

START: FULL LICENSE


THE FULL PROJECT GUTENBERG LICENSE
PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK

To protect the Project Gutenberg™ mission of promoting the


free distribution of electronic works, by using or distributing this
work (or any other work associated in any way with the phrase
“Project Gutenberg”), you agree to comply with all the terms of
the Full Project Gutenberg™ License available with this file or
online at www.gutenberg.org/license.

Section 1. General Terms of Use and


Redistributing Project Gutenberg™
electronic works
1.A. By reading or using any part of this Project Gutenberg™
electronic work, you indicate that you have read, understand,
agree to and accept all the terms of this license and intellectual
property (trademark/copyright) agreement. If you do not agree
to abide by all the terms of this agreement, you must cease
using and return or destroy all copies of Project Gutenberg™
electronic works in your possession. If you paid a fee for
obtaining a copy of or access to a Project Gutenberg™
electronic work and you do not agree to be bound by the terms
of this agreement, you may obtain a refund from the person or
entity to whom you paid the fee as set forth in paragraph 1.E.8.

1.B. “Project Gutenberg” is a registered trademark. It may only


be used on or associated in any way with an electronic work by
people who agree to be bound by the terms of this agreement.
There are a few things that you can do with most Project
Gutenberg™ electronic works even without complying with the
full terms of this agreement. See paragraph 1.C below. There
are a lot of things you can do with Project Gutenberg™
electronic works if you follow the terms of this agreement and
help preserve free future access to Project Gutenberg™
electronic works. See paragraph 1.E below.
1.C. The Project Gutenberg Literary Archive Foundation (“the
Foundation” or PGLAF), owns a compilation copyright in the
collection of Project Gutenberg™ electronic works. Nearly all the
individual works in the collection are in the public domain in the
United States. If an individual work is unprotected by copyright
law in the United States and you are located in the United
States, we do not claim a right to prevent you from copying,
distributing, performing, displaying or creating derivative works
based on the work as long as all references to Project
Gutenberg are removed. Of course, we hope that you will
support the Project Gutenberg™ mission of promoting free
access to electronic works by freely sharing Project Gutenberg™
works in compliance with the terms of this agreement for
keeping the Project Gutenberg™ name associated with the
work. You can easily comply with the terms of this agreement
by keeping this work in the same format with its attached full
Project Gutenberg™ License when you share it without charge
with others.

1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside
the United States, check the laws of your country in addition to
the terms of this agreement before downloading, copying,
displaying, performing, distributing or creating derivative works
based on this work or any other Project Gutenberg™ work. The
Foundation makes no representations concerning the copyright
status of any work in any country other than the United States.

1.E. Unless you have removed all references to Project


Gutenberg:

1.E.1. The following sentence, with active links to, or other


immediate access to, the full Project Gutenberg™ License must
appear prominently whenever any copy of a Project
Gutenberg™ work (any work on which the phrase “Project
Gutenberg” appears, or with which the phrase “Project
Gutenberg” is associated) is accessed, displayed, performed,
viewed, copied or distributed:

This eBook is for the use of anyone anywhere in the United


States and most other parts of the world at no cost and
with almost no restrictions whatsoever. You may copy it,
give it away or re-use it under the terms of the Project
Gutenberg License included with this eBook or online at
www.gutenberg.org. If you are not located in the United
States, you will have to check the laws of the country
where you are located before using this eBook.

1.E.2. If an individual Project Gutenberg™ electronic work is


derived from texts not protected by U.S. copyright law (does not
contain a notice indicating that it is posted with permission of
the copyright holder), the work can be copied and distributed to
anyone in the United States without paying any fees or charges.
If you are redistributing or providing access to a work with the
phrase “Project Gutenberg” associated with or appearing on the
work, you must comply either with the requirements of
paragraphs 1.E.1 through 1.E.7 or obtain permission for the use
of the work and the Project Gutenberg™ trademark as set forth
in paragraphs 1.E.8 or 1.E.9.

1.E.3. If an individual Project Gutenberg™ electronic work is


posted with the permission of the copyright holder, your use and
distribution must comply with both paragraphs 1.E.1 through
1.E.7 and any additional terms imposed by the copyright holder.
Additional terms will be linked to the Project Gutenberg™
License for all works posted with the permission of the copyright
holder found at the beginning of this work.

1.E.4. Do not unlink or detach or remove the full Project


Gutenberg™ License terms from this work, or any files
containing a part of this work or any other work associated with
Project Gutenberg™.

1.E.5. Do not copy, display, perform, distribute or redistribute


this electronic work, or any part of this electronic work, without
prominently displaying the sentence set forth in paragraph 1.E.1
with active links or immediate access to the full terms of the
Project Gutenberg™ License.

1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if
you provide access to or distribute copies of a Project
Gutenberg™ work in a format other than “Plain Vanilla ASCII” or
other format used in the official version posted on the official
Project Gutenberg™ website (www.gutenberg.org), you must,
at no additional cost, fee or expense to the user, provide a copy,
a means of exporting a copy, or a means of obtaining a copy
upon request, of the work in its original “Plain Vanilla ASCII” or
other form. Any alternate format must include the full Project
Gutenberg™ License as specified in paragraph 1.E.1.

1.E.7. Do not charge a fee for access to, viewing, displaying,


performing, copying or distributing any Project Gutenberg™
works unless you comply with paragraph 1.E.8 or 1.E.9.

1.E.8. You may charge a reasonable fee for copies of or


providing access to or distributing Project Gutenberg™
electronic works provided that:

• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”

• You provide a full refund of any money paid by a user who


notifies you in writing (or by e-mail) within 30 days of receipt
that s/he does not agree to the terms of the full Project
Gutenberg™ License. You must require such a user to return or
destroy all copies of the works possessed in a physical medium
and discontinue all use of and all access to other copies of
Project Gutenberg™ works.

• You provide, in accordance with paragraph 1.F.3, a full refund of


any money paid for a work or a replacement copy, if a defect in
the electronic work is discovered and reported to you within 90
days of receipt of the work.

• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.

1.E.9. If you wish to charge a fee or distribute a Project


Gutenberg™ electronic work or group of works on different
terms than are set forth in this agreement, you must obtain
permission in writing from the Project Gutenberg Literary
Archive Foundation, the manager of the Project Gutenberg™
trademark. Contact the Foundation as set forth in Section 3
below.

1.F.

1.F.1. Project Gutenberg volunteers and employees expend


considerable effort to identify, do copyright research on,
transcribe and proofread works not protected by U.S. copyright
law in creating the Project Gutenberg™ collection. Despite these
efforts, Project Gutenberg™ electronic works, and the medium
on which they may be stored, may contain “Defects,” such as,
but not limited to, incomplete, inaccurate or corrupt data,
transcription errors, a copyright or other intellectual property
infringement, a defective or damaged disk or other medium, a
computer virus, or computer codes that damage or cannot be
read by your equipment.

1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES - Except


for the “Right of Replacement or Refund” described in
paragraph 1.F.3, the Project Gutenberg Literary Archive
Foundation, the owner of the Project Gutenberg™ trademark,
and any other party distributing a Project Gutenberg™ electronic
work under this agreement, disclaim all liability to you for
damages, costs and expenses, including legal fees. YOU AGREE
THAT YOU HAVE NO REMEDIES FOR NEGLIGENCE, STRICT
LIABILITY, BREACH OF WARRANTY OR BREACH OF CONTRACT
EXCEPT THOSE PROVIDED IN PARAGRAPH 1.F.3. YOU AGREE
THAT THE FOUNDATION, THE TRADEMARK OWNER, AND ANY
DISTRIBUTOR UNDER THIS AGREEMENT WILL NOT BE LIABLE
TO YOU FOR ACTUAL, DIRECT, INDIRECT, CONSEQUENTIAL,
PUNITIVE OR INCIDENTAL DAMAGES EVEN IF YOU GIVE
NOTICE OF THE POSSIBILITY OF SUCH DAMAGE.

1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If you


discover a defect in this electronic work within 90 days of
receiving it, you can receive a refund of the money (if any) you
paid for it by sending a written explanation to the person you
received the work from. If you received the work on a physical
medium, you must return the medium with your written
explanation. The person or entity that provided you with the
defective work may elect to provide a replacement copy in lieu
of a refund. If you received the work electronically, the person
or entity providing it to you may choose to give you a second
opportunity to receive the work electronically in lieu of a refund.
If the second copy is also defective, you may demand a refund
in writing without further opportunities to fix the problem.

1.F.4. Except for the limited right of replacement or refund set


forth in paragraph 1.F.3, this work is provided to you ‘AS-IS’,
WITH NO OTHER WARRANTIES OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.

1.F.5. Some states do not allow disclaimers of certain implied


warranties or the exclusion or limitation of certain types of
damages. If any disclaimer or limitation set forth in this
agreement violates the law of the state applicable to this
agreement, the agreement shall be interpreted to make the
maximum disclaimer or limitation permitted by the applicable
state law. The invalidity or unenforceability of any provision of
this agreement shall not void the remaining provisions.

1.F.6. INDEMNITY - You agree to indemnify and hold the


Foundation, the trademark owner, any agent or employee of the
Foundation, anyone providing copies of Project Gutenberg™
electronic works in accordance with this agreement, and any
volunteers associated with the production, promotion and
distribution of Project Gutenberg™ electronic works, harmless
from all liability, costs and expenses, including legal fees, that
arise directly or indirectly from any of the following which you
do or cause to occur: (a) distribution of this or any Project
Gutenberg™ work, (b) alteration, modification, or additions or
deletions to any Project Gutenberg™ work, and (c) any Defect
you cause.

Section 2. Information about the Mission


of Project Gutenberg™
Project Gutenberg™ is synonymous with the free distribution of
electronic works in formats readable by the widest variety of
computers including obsolete, old, middle-aged and new
computers. It exists because of the efforts of hundreds of
volunteers and donations from people in all walks of life.

Volunteers and financial support to provide volunteers with the


assistance they need are critical to reaching Project
Gutenberg™’s goals and ensuring that the Project Gutenberg™
collection will remain freely available for generations to come. In
2001, the Project Gutenberg Literary Archive Foundation was
created to provide a secure and permanent future for Project
Gutenberg™ and future generations. To learn more about the
Project Gutenberg Literary Archive Foundation and how your
efforts and donations can help, see Sections 3 and 4 and the
Foundation information page at www.gutenberg.org.

Section 3. Information about the Project


Gutenberg Literary Archive Foundation
The Project Gutenberg Literary Archive Foundation is a non-
profit 501(c)(3) educational corporation organized under the
laws of the state of Mississippi and granted tax exempt status
by the Internal Revenue Service. The Foundation’s EIN or
federal tax identification number is 64-6221541. Contributions
to the Project Gutenberg Literary Archive Foundation are tax
deductible to the full extent permitted by U.S. federal laws and
your state’s laws.

The Foundation’s business office is located at 809 North 1500


West, Salt Lake City, UT 84116, (801) 596-1887. Email contact
links and up to date contact information can be found at the
Foundation’s website and official page at
www.gutenberg.org/contact
Section 4. Information about Donations to
the Project Gutenberg Literary Archive
Foundation
Project Gutenberg™ depends upon and cannot survive without
widespread public support and donations to carry out its mission
of increasing the number of public domain and licensed works
that can be freely distributed in machine-readable form
accessible by the widest array of equipment including outdated
equipment. Many small donations ($1 to $5,000) are particularly
important to maintaining tax exempt status with the IRS.

The Foundation is committed to complying with the laws


regulating charities and charitable donations in all 50 states of
the United States. Compliance requirements are not uniform
and it takes a considerable effort, much paperwork and many
fees to meet and keep up with these requirements. We do not
solicit donations in locations where we have not received written
confirmation of compliance. To SEND DONATIONS or determine
the status of compliance for any particular state visit
www.gutenberg.org/donate.

While we cannot and do not solicit contributions from states


where we have not met the solicitation requirements, we know
of no prohibition against accepting unsolicited donations from
donors in such states who approach us with offers to donate.

International donations are gratefully accepted, but we cannot


make any statements concerning tax treatment of donations
received from outside the United States. U.S. laws alone swamp
our small staff.

Please check the Project Gutenberg web pages for current


donation methods and addresses. Donations are accepted in a
number of other ways including checks, online payments and
credit card donations. To donate, please visit:
www.gutenberg.org/donate.

Section 5. General Information About


Project Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could
be freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose
network of volunteer support.

Project Gutenberg™ eBooks are often created from several


printed editions, all of which are confirmed as not protected by
copyright in the U.S. unless a copyright notice is included. Thus,
we do not necessarily keep eBooks in compliance with any
particular paper edition.

Most people start at our website which has the main PG search
facility: www.gutenberg.org.

This website includes information about Project Gutenberg™,


including how to make donations to the Project Gutenberg
Literary Archive Foundation, how to help produce our new
eBooks, and how to subscribe to our email newsletter to hear
about new eBooks.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

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

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookultra.com

You might also like