SlideShare a Scribd company logo
Read Anytime Anywhere Easy Ebook Downloads at ebookluna.com
(eBook PDF) Java How to Program, Late Objects
Global Edition 11th Edition
https://ebookluna.com/product/ebook-pdf-java-how-to-program-
late-objects-global-edition-11th-edition/
OR CLICK HERE
DOWLOAD EBOOK
Visit and Get More Ebook Downloads Instantly at https://ebookluna.com
Instant digital products (PDF, ePub, MOBI) available
Download now and explore formats that suit you...
(eBook PDF) Java How To Program (Early Objects) 10th
https://ebookluna.com/product/ebook-pdf-java-how-to-program-early-
objects-10th/
ebookluna.com
(eBook PDF) Java How to Program, Early Objects 11th
Edition by Paul J. Deitel
https://ebookluna.com/product/ebook-pdf-java-how-to-program-early-
objects-11th-edition-by-paul-j-deitel/
ebookluna.com
(eBook PDF) Java Concepts: Late Objects, 3rd Edition
https://ebookluna.com/product/ebook-pdf-java-concepts-late-
objects-3rd-edition/
ebookluna.com
(eBook PDF) Big Java Late Objects 2nd Edition
https://ebookluna.com/product/ebook-pdf-big-java-late-objects-2nd-
edition/
ebookluna.com
C++ How to Program: An Objects-Natural Approach, 11e 11th
Edition Paul Deitel - eBook PDF
https://ebookluna.com/download/c-how-to-program-an-objects-natural-
approach-11e-ebook-pdf/
ebookluna.com
C++ How to Program Early Objects Version 9th Edition
(eBook PDF)
https://ebookluna.com/product/c-how-to-program-early-objects-
version-9th-edition-ebook-pdf/
ebookluna.com
C How to Program, 9th Global Edition Deitel Paul - eBook
PDF
https://ebookluna.com/download/c-how-to-program-9th-global-edition-
ebook-pdf/
ebookluna.com
(eBook PDF) Big C++: Late Objects 3rd Edition
https://ebookluna.com/product/ebook-pdf-big-c-late-objects-3rd-
edition/
ebookluna.com
(eBook PDF) Brief C++: Late Objects, 3rd Edition
https://ebookluna.com/product/ebook-pdf-brief-c-late-objects-3rd-
edition/
ebookluna.com
(eBook PDF) Java How to Program, Late Objects Global Edition 11th Edition
(eBook PDF) Java How to Program, Late Objects Global Edition 11th Edition
Trademarks
DEITEL and the double-thumbs-up bug are registered trademarks of Deitel and Associates, Inc.
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks
of their respective owners.
Microsoft and/or its respective suppliers make no representations about the suitability of the information
contained in the documents and related graphics published as part of the services for any purpose. All
such documents and related graphics are provided “as is” without warranty of any kind. Microsoft and/
or its respective suppliers hereby disclaim all warranties and conditions with regard to this information,
including all warranties and conditions of merchantability, whether express, implied or statutory, fitness
for a particular purpose, title and non-infringement. In no event shall Microsoft and/or its respective sup-
pliers be liable for any special, indirect or consequential damages or any damages whatsoever resulting
from loss of use, data or profits, whether in an action of contract, negligence or other tortious action,
arising out of or in connection with the use or performance of information available from the services.
The documents and related graphics contained herein could include technical inaccuracies or typograph-
ical errors. Changes are periodically added to the information herein. Microsoft and/or its respective sup-
pliers may make improvements and/or changes in the product(s) and/or the program(s) described herein
at any time. Partial screen shots may be viewed in full within the software version specified.
Microsoft® and Windows® are registered trademarks of the Microsoft Corporation in the U.S.A. and
other countries. Screen shots and icons reprinted with permission from the Microsoft Corporation. This
book is not sponsored or endorsed by or affiliated with the Microsoft Corporation.
UNIX is a registered trademark of The Open Group.
Apache is a trademark of The Apache Software Foundation.
CSS and XML are registered trademarks of the World Wide Web Consortium.
Firefox is a registered trademark of the Mozilla Foundation.
Google is a trademark of Google, Inc.
Mac and macOS are trademarks of Apple Inc., registered in the U.S. and other countries.
Linux is a registered trademark of Linus Torvalds. All trademarks are property of their respective owners.
Throughout this book, trademarks are used. Rather than put a trademark symbol in every occurrence of
a trademarked name, we state that we are using the names in an editorial fashion only and to the benefit
of the trademark owner, with no intention of infringement of the trademark.
The online chapters and appendices listed at the end of this Table of Contents are located
on the book’s Companion Website (http://www.pearsonglobaleditions.com)—see
the inside front cover of your book for details.
Foreword 25
Preface 27
Before You Begin 47
1 Introduction to Computers, the Internet and Java 53
1.1 Introduction 54
1.2 Hardware and Software 56
1.2.1 Moore’s Law 56
1.2.2 Computer Organization 57
1.3 Data Hierarchy 59
1.4 Machine Languages, Assembly Languages and High-Level Languages 61
1.5 Basic Introduction to Object Terminology 62
1.5.1 Automobile as an Object 63
1.5.2 Methods and Classes 63
1.5.3 Instantiation 63
1.5.4 Reuse 63
1.5.5 Messages and Method Calls 64
1.5.6 Attributes and Instance Variables 64
1.5.7 Encapsulation and Information Hiding 64
1.5.8 Inheritance 64
1.5.9 Interfaces 65
1.5.10 Object-Oriented Analysis and Design (OOAD) 65
1.5.11 The UML (Unified Modeling Language) 65
1.6 Operating Systems 66
1.6.1 Windows—A Proprietary Operating System 66
1.6.2 Linux—An Open-Source Operating System 66
1.6.3 Apple’s macOS and Apple’s iOS for iPhone®, iPad® and
iPod Touch® Devices 67
1.6.4 Google’s Android 67
Contents
8 Contents
1.7 Programming Languages 68
1.8 Java 70
1.9 A Typical Java Development Environment 71
1.10 Test-Driving a Java Application 74
1.11 Internet and World Wide Web 78
1.11.1 Internet: A Network of Networks 79
1.11.2 World Wide Web: Making the Internet User-Friendly 79
1.11.3 Web Services and Mashups 79
1.11.4 Internet of Things 80
1.12 Software Technologies 81
1.13 Getting Your Questions Answered 83
2 Introduction to Java Applications; Input/Output
and Operators 87
2.1 Introduction 88
2.2 Your First Program in Java: Printing a Line of Text 88
2.2.1 Compiling the Application 92
2.2.2 Executing the Application 93
2.3 Modifying Your First Java Program 94
2.4 Displaying Text with printf 96
2.5 Another Application: Adding Integers 97
2.5.1 import Declarations 98
2.5.2 Declaring and Creating a Scanner to Obtain User Input
from the Keyboard 98
2.5.3 Prompting the User for Input 99
2.5.4 Declaring a Variable to Store an Integer and Obtaining an
Integer from the Keyboard 99
2.5.5 Obtaining a Second Integer 100
2.5.6 Using Variables in a Calculation 100
2.5.7 Displaying the Calculation Result 100
2.5.8 Java API Documentation 101
2.5.9 Declaring and Initializing Variables in Separate Statements 101
2.6 Memory Concepts 101
2.7 Arithmetic 102
2.8 Decision Making: Equality and Relational Operators 106
2.9 Wrap-Up 109
3 Control Statements: Part 1; Assignment,
++ and -- Operators 120
3.1 Introduction 121
3.2 Algorithms 121
3.3 Pseudocode 122
3.4 Control Structures 122
3.4.1 Sequence Structure in Java 123
Contents 9
3.4.2 Selection Statements in Java 124
3.4.3 Iteration Statements in Java 124
3.4.4 Summary of Control Statements in Java 124
3.5 if Single-Selection Statement 125
3.6 if…else Double-Selection Statement 126
3.6.1 Nested if…else Statements 127
3.6.2 Dangling-else Problem 128
3.6.3 Blocks 128
3.6.4 Conditional Operator (?:) 129
3.7 while Iteration Statement 129
3.8 Formulating Algorithms: Counter-Controlled Iteration 131
3.9 Formulating Algorithms: Sentinel-Controlled Iteration 135
3.10 Formulating Algorithms: Nested Control Statements 142
3.11 Compound Assignment Operators 146
3.12 Increment and Decrement Operators 147
3.13 Primitive Types 150
3.14 Wrap-Up 150
4 Control Statements: Part 2; Logical Operators 164
4.1 Introduction 165
4.2 Essentials of Counter-Controlled Iteration 165
4.3 for Iteration Statement 166
4.4 Examples Using the for Statement 170
4.4.1 Application: Summing the Even Integers from 2 to 20 171
4.4.2 Application: Compound-Interest Calculations 172
4.5 do…while Iteration Statement 175
4.6 switch Multiple-Selection Statement 176
4.7 break and continue Statements 182
4.7.1 break Statement 182
4.7.2 continue Statement 182
4.8 Logical Operators 183
4.8.1 Conditional AND (&&) Operator 184
4.8.2 Conditional OR (||) Operator 184
4.8.3 Short-Circuit Evaluation of Complex Conditions 185
4.8.4 Boolean Logical AND (&) and Boolean Logical Inclusive OR (|)
Operators 185
4.8.5 Boolean Logical Exclusive OR (^) 186
4.8.6 Logical Negation (!) Operator 186
4.8.7 Logical Operators Example 187
4.9 Structured-Programming Summary 189
4.10 Wrap-Up 194
5 Methods 204
5.1 Introduction 205
10 Contents
5.2 Program Units in Java 205
5.3 static Methods, static Variables and Class Math 207
5.4 Declaring Methods 209
5.5 Notes on Declaring and Using Methods 213
5.6 Method-Call Stack and Activation Records 214
5.6.1 Method-Call Stack 214
5.6.2 Stack Frames 214
5.6.3 Local Variables and Stack Frames 215
5.6.4 Stack Overflow 215
5.7 Argument Promotion and Casting 215
5.8 Java API Packages 216
5.9 Case Study: Secure Random-Number Generation 218
5.10 Case Study: A Game of Chance; Introducing enums 223
5.11 Scope of Declarations 227
5.12 Method Overloading 230
5.12.1 Declaring Overloaded Methods 230
5.12.2 Distinguishing Between Overloaded Methods 231
5.12.3 Return Types of Overloaded Methods 231
5.13 Wrap-Up 232
6 Arrays and ArrayLists 245
6.1 Introduction 246
6.2 Primitive Types vs. Reference Types 247
6.3 Arrays 247
6.4 Declaring and Creating Arrays 249
6.5 Examples Using Arrays 250
6.5.1 Creating and Initializing an Array 250
6.5.2 Using an Array Initializer 251
6.5.3 Calculating the Values to Store in an Array 252
6.5.4 Summing the Elements of an Array 253
6.5.5 Using Bar Charts to Display Array Data Graphically 254
6.5.6 Using the Elements of an Array as Counters 256
6.5.7 Using Arrays to Analyze Survey Results 257
6.6 Exception Handling: Processing the Incorrect Response 259
6.6.1 The try Statement 259
6.6.2 Executing the catch Block 259
6.6.3 toString Method of the Exception Parameter 260
6.7 Enhanced for Statement 260
6.8 Passing Arrays to Methods 261
6.9 Pass-By-Value vs. Pass-By-Reference 264
6.10 Multidimensional Arrays 264
6.10.1 Arrays of One-Dimensional Arrays 265
6.10.2 Two-Dimensional Arrays with Rows of Different Lengths 265
6.10.3 Creating Two-Dimensional Arrays with Array-Creation
Expressions 266
Contents 11
6.10.4 Two-Dimensional Array Example: Displaying Element Values 266
6.10.5 Common Multidimensional-Array Manipulations Performed
with for Statements 267
6.11 Variable-Length Argument Lists 268
6.12 Using Command-Line Arguments 269
6.13 Class Arrays 271
6.14 Introduction to Collections and Class ArrayList 274
6.15 Wrap-Up 278
7 Introduction to Classes and Objects 298
7.1 Introduction 299
7.2 Instance Variables, set Methods and get Methods 300
7.2.1 Account Class with an Instance Variable, and set and get Methods 300
7.2.2 AccountTest Class That Creates and Uses an Object of
Class Account 302
7.2.3 Compiling and Executing an App with Multiple Classes 305
7.2.4 Account UML Class Diagram 305
7.2.5 Additional Notes on Class AccountTest 306
7.2.6 Software Engineering with private Instance Variables and
public set and get Methods 307
7.3 Default and Explicit Initialization for Instance Variables 308
7.4 Account Class: Initializing Objects with Constructors 309
7.4.1 Declaring an Account Constructor for Custom Object
Initialization 309
7.4.2 Class AccountTest: Initializing Account Objects When
They’re Created 310
7.5 Account Class with a Balance 312
7.5.1 Account Class with a balance Instance Variable of Type double 312
7.5.2 AccountTest Class to Use Class Account 313
7.6 Case Study: Card Shuffling and Dealing Simulation 316
7.7 Case Study: Class GradeBook Using an Array to Store Grades 320
7.8 Case Study: Class GradeBook Using a Two-Dimensional Array 326
7.9 Wrap-Up 331
8 Classes and Objects: A Deeper Look 339
8.1 Introduction 340
8.2 Time Class Case Study 340
8.3 Controlling Access to Members 345
8.4 Referring to the Current Object’s Members with the this Reference 346
8.5 Time Class Case Study: Overloaded Constructors 348
8.6 Default and No-Argument Constructors 353
8.7 Notes on Set and Get Methods 354
8.8 Composition 355
8.9 enum Types 358
12 Contents
8.10 Garbage Collection 361
8.11 static Class Members 361
8.12 static Import 365
8.13 final Instance Variables 366
8.14 Package Access 367
8.15 Using BigDecimal for Precise Monetary Calculations 368
8.16 (Optional) GUI and Graphics Case Study: Using Objects with Graphics 371
8.17 Wrap-Up 375
9 Object-Oriented Programming: Inheritance 383
9.1 Introduction 384
9.2 Superclasses and Subclasses 385
9.3 protected Members 387
9.4 Relationship Between Superclasses and Subclasses 388
9.4.1 Creating and Using a CommissionEmployee Class 388
9.4.2 Creating and Using a BasePlusCommissionEmployee Class 393
9.4.3 Creating a CommissionEmployee–BasePlusCommissionEmployee
Inheritance Hierarchy 398
9.4.4 CommissionEmployee–BasePlusCommissionEmployee
Inheritance Hierarchy Using protected Instance Variables 401
9.4.5 CommissionEmployee–BasePlusCommissionEmployee Inheritance
Hierarchy Using private Instance Variables 404
9.5 Constructors in Subclasses 408
9.6 Class Object 409
9.7 Designing with Composition vs. Inheritance 410
9.8 Wrap-Up 412
10 Object-Oriented Programming: Polymorphism
and Interfaces 417
10.1 Introduction 418
10.2 Polymorphism Examples 420
10.3 Demonstrating Polymorphic Behavior 421
10.4 Abstract Classes and Methods 423
10.5 Case Study: Payroll System Using Polymorphism 426
10.5.1 Abstract Superclass Employee 427
10.5.2 Concrete Subclass SalariedEmployee 429
10.5.3 Concrete Subclass HourlyEmployee 431
10.5.4 Concrete Subclass CommissionEmployee 432
10.5.5 Indirect Concrete Subclass BasePlusCommissionEmployee 434
10.5.6 Polymorphic Processing, Operator instanceof and Downcasting 435
10.6 Allowed Assignments Between Superclass and Subclass Variables 440
10.7 final Methods and Classes 440
10.8 A Deeper Explanation of Issues with Calling Methods from Constructors 441
10.9 Creating and Using Interfaces 442
10.9.1 Developing a Payable Hierarchy 444
Contents 13
10.9.2 Interface Payable 445
10.9.3 Class Invoice 445
10.9.4 Modifying Class Employee to Implement Interface Payable 447
10.9.5 Using Interface Payable to Process Invoices and Employees
Polymorphically 449
10.9.6 Some Common Interfaces of the Java API 450
10.10 Java SE 8 Interface Enhancements 451
10.10.1 default Interface Methods 451
10.10.2 static Interface Methods 452
10.10.3 Functional Interfaces 452
10.11 Java SE 9 private Interface Methods 453
10.12 private Constructors 453
10.13 Program to an Interface, Not an Implementation 454
10.13.1 Implementation Inheritance Is Best for Small Numbers of
Tightly Coupled Classes 454
10.13.2 Interface Inheritance Is Best for Flexibility 454
10.13.3 Rethinking the Employee Hierarchy 455
10.14 (Optional) GUI and Graphics Case Study: Drawing with Polymorphism 456
10.15 Wrap-Up 458
11 Exception Handling: A Deeper Look 465
11.1 Introduction 466
11.2 Example: Divide by Zero without Exception Handling 467
11.3 Example: Handling ArithmeticExceptions and
InputMismatchExceptions 469
11.4 When to Use Exception Handling 475
11.5 Java Exception Hierarchy 475
11.6 finally Block 479
11.7 Stack Unwinding and Obtaining Information from an Exception 483
11.8 Chained Exceptions 486
11.9 Declaring New Exception Types 488
11.10 Preconditions and Postconditions 489
11.11 Assertions 489
11.12 try-with-Resources: Automatic Resource Deallocation 491
11.13 Wrap-Up 492
12 JavaFX Graphical User Interfaces: Part 1 498
12.1 Introduction 499
12.2 JavaFX Scene Builder 500
12.3 JavaFX App Window Structure 501
12.4 Welcome App—Displaying Text and an Image 502
12.4.1 Opening Scene Builder and Creating the File Welcome.fxml 502
12.4.2 Adding an Image to the Folder Containing Welcome.fxml 503
12.4.3 Creating a VBox Layout Container 503
12.4.4 Configuring the VBox Layout Container 504
12.4.5 Adding and Configuring a Label 504
14 Contents
12.4.6 Adding and Configuring an ImageView 505
12.4.7 Previewing the Welcome GUI 507
12.5 Tip Calculator App—Introduction to Event Handling 507
12.5.1 Test-Driving the Tip Calculator App 508
12.5.2 Technologies Overview 509
12.5.3 Building the App’s GUI 511
12.5.4 TipCalculator Class 518
12.5.5 TipCalculatorController Class 520
12.6 Features Covered in the Other JavaFX Chapters 525
12.7 Wrap-Up 525
13 JavaFX GUI: Part 2 533
13.1 Introduction 534
13.2 Laying Out Nodes in a Scene Graph 534
13.3 Painter App: RadioButtons, Mouse Events and Shapes 536
13.3.1 Technologies Overview 536
13.3.2 Creating the Painter.fxml File 538
13.3.3 Building the GUI 538
13.3.4 Painter Subclass of Application 541
13.3.5 PainterController Class 542
13.4 Color Chooser App: Property Bindings and Property Listeners 546
13.4.1 Technologies Overview 546
13.4.2 Building the GUI 547
13.4.3 ColorChooser Subclass of Application 549
13.4.4 ColorChooserController Class 550
13.5 Cover Viewer App: Data-Driven GUIs with JavaFX Collections 552
13.5.1 Technologies Overview 553
13.5.2 Adding Images to the App’s Folder 553
13.5.3 Building the GUI 553
13.5.4 CoverViewer Subclass of Application 555
13.5.5 CoverViewerController Class 555
13.6 Cover Viewer App: Customizing ListView Cells 557
13.6.1 Technologies Overview 558
13.6.2 Copying the CoverViewer App 558
13.6.3 ImageTextCell Custom Cell Factory Class 559
13.6.4 CoverViewerController Class 560
13.7 Additional JavaFX Capabilities 561
13.8 JavaFX 9: Java SE 9 JavaFX Updates 563
13.9 Wrap-Up 565
14 Strings, Characters and Regular Expressions 574
14.1 Introduction 575
14.2 Fundamentals of Characters and Strings 575
14.3 Class String 576
14.3.1 String Constructors 576
Visit https://testbankfan.com
now to explore a rich
collection of testbank or
solution manual and enjoy
exciting offers!
Contents 15
14.3.2 String Methods length, charAt and getChars 577
14.3.3 Comparing Strings 579
14.3.4 Locating Characters and Substrings in Strings 583
14.3.5 Extracting Substrings from Strings 585
14.3.6 Concatenating Strings 586
14.3.7 Miscellaneous String Methods 587
14.3.8 String Method valueOf 588
14.4 Class StringBuilder 589
14.4.1 StringBuilder Constructors 590
14.4.2 StringBuilder Methods length, capacity, setLength and
ensureCapacity 591
14.4.3 StringBuilder Methods charAt, setCharAt, getChars and
reverse 592
14.4.4 StringBuilder append Methods 593
14.4.5 StringBuilder Insertion and Deletion Methods 595
14.5 Class Character 596
14.6 Tokenizing Strings 601
14.7 Regular Expressions, Class Pattern and Class Matcher 602
14.7.1 Replacing Substrings and Splitting Strings 607
14.7.2 Classes Pattern and Matcher 609
14.8 Wrap-Up 611
15 Files, Input/Output Streams, NIO and
XML Serialization 622
15.1 Introduction 623
15.2 Files and Streams 623
15.3 Using NIO Classes and Interfaces to Get File and Directory Information 625
15.4 Sequential Text Files 629
15.4.1 Creating a Sequential Text File 629
15.4.2 Reading Data from a Sequential Text File 632
15.4.3 Case Study: A Credit-Inquiry Program 633
15.4.4 Updating Sequential Files 638
15.5 XML Serialization 638
15.5.1 Creating a Sequential File Using XML Serialization 638
15.5.2 Reading and Deserializing Data from a Sequential File 644
15.6 FileChooser and DirectoryChooser Dialogs 645
15.7 (Optional) Additional java.io Classes 651
15.7.1 Interfaces and Classes for Byte-Based Input and Output 651
15.7.2 Interfaces and Classes for Character-Based Input and Output 653
15.8 Wrap-Up 654
16 Generic Collections 662
16.1 Introduction 663
16.2 Collections Overview 663
16 Contents
16.3 Type-Wrapper Classes 665
16.4 Autoboxing and Auto-Unboxing 665
16.5 Interface Collection and Class Collections 665
16.6 Lists 666
16.6.1 ArrayList and Iterator 667
16.6.2 LinkedList 669
16.7 Collections Methods 674
16.7.1 Method sort 674
16.7.2 Method shuffle 678
16.7.3 Methods reverse, fill, copy, max and min 680
16.7.4 Method binarySearch 682
16.7.5 Methods addAll, frequency and disjoint 683
16.8 Class PriorityQueue and Interface Queue 685
16.9 Sets 686
16.10 Maps 689
16.11 Synchronized Collections 693
16.12 Unmodifiable Collections 693
16.13 Abstract Implementations 694
16.14 Java SE 9: Convenience Factory Methods for Immutable Collections 694
16.15 Wrap-Up 698
17 Lambdas and Streams 704
17.1 Introduction 705
17.2 Streams and Reduction 707
17.2.1 Summing the Integers from 1 through 10 with a for Loop 707
17.2.2 External Iteration with for Is Error Prone 708
17.2.3 Summing with a Stream and Reduction 708
17.2.4 Internal Iteration 709
17.3 Mapping and Lambdas 710
17.3.1 Lambda Expressions 711
17.3.2 Lambda Syntax 712
17.3.3 Intermediate and Terminal Operations 713
17.4 Filtering 714
17.5 How Elements Move Through Stream Pipelines 716
17.6 Method References 717
17.6.1 Creating an IntStream of Random Values 718
17.6.2 Performing a Task on Each Stream Element with forEach and
a Method Reference 718
17.6.3 Mapping Integers to String Objects with mapToObj 719
17.6.4 Concatenating Strings with collect 719
17.7 IntStream Operations 720
17.7.1 Creating an IntStream and Displaying Its Values 721
17.7.2 Terminal Operations count, min, max, sum and average 721
17.7.3 Terminal Operation reduce 722
17.7.4 Sorting IntStream Values 724
Contents 17
17.8 Functional Interfaces 725
17.9 Lambdas: A Deeper Look 726
17.10 Stream<Integer> Manipulations 727
17.10.1 Creating a Stream<Integer> 728
17.10.2 Sorting a Stream and Collecting the Results 729
17.10.3 Filtering a Stream and Storing the Results for Later Use 729
17.10.4 Filtering and Sorting a Stream and Collecting the Results 730
17.10.5 Sorting Previously Collected Results 730
17.11 Stream<String> Manipulations 730
17.11.1 Mapping Strings to Uppercase 731
17.11.2 Filtering Strings Then Sorting Them in Case-Insensitive
Ascending Order 732
17.11.3 Filtering Strings Then Sorting Them in Case-Insensitive
Descending Order 732
17.12 Stream<Employee> Manipulations 733
17.12.1 Creating and Displaying a List<Employee> 734
17.12.2 Filtering Employees with Salaries in a Specified Range 735
17.12.3 Sorting Employees By Multiple Fields 738
17.12.4 Mapping Employees to Unique-Last-Name Strings 740
17.12.5 Grouping Employees By Department 741
17.12.6 Counting the Number of Employees in Each Department 742
17.12.7 Summing and Averaging Employee Salaries 743
17.13 Creating a Stream<String> from a File 744
17.14 Streams of Random Values 747
17.15 Infinite Streams 749
17.16 Lambda Event Handlers 751
17.17 Additional Notes on Java SE 8 Interfaces 751
17.18 Wrap-Up 752
18 Recursion 766
18.1 Introduction 767
18.2 Recursion Concepts 768
18.3 Example Using Recursion: Factorials 769
18.4 Reimplementing Class FactorialCalculator Using BigInteger 771
18.5 Example Using Recursion: Fibonacci Series 773
18.6 Recursion and the Method-Call Stack 776
18.7 Recursion vs. Iteration 777
18.8 Towers of Hanoi 779
18.9 Fractals 781
18.9.1 Koch Curve Fractal 782
18.9.2 (Optional) Case Study: Lo Feather Fractal 783
18.9.3 (Optional) Fractal App GUI 785
18.9.4 (Optional) FractalController Class 787
18.10 Recursive Backtracking 792
18.11 Wrap-Up 792
18 Contents
19 Searching, Sorting and Big O 801
19.1 Introduction 802
19.2 Linear Search 803
19.3 Big O Notation 806
19.3.1 O(1) Algorithms 806
19.3.2 O(n) Algorithms 806
19.3.3 O(n2) Algorithms 806
19.3.4 Big O of the Linear Search 807
19.4 Binary Search 807
19.4.1 Binary Search Implementation 808
19.4.2 Efficiency of the Binary Search 811
19.5 Sorting Algorithms 812
19.6 Selection Sort 812
19.6.1 Selection Sort Implementation 813
19.6.2 Efficiency of the Selection Sort 815
19.7 Insertion Sort 815
19.7.1 Insertion Sort Implementation 816
19.7.2 Efficiency of the Insertion Sort 818
19.8 Merge Sort 819
19.8.1 Merge Sort Implementation 819
19.8.2 Efficiency of the Merge Sort 824
19.9 Big O Summary for This Chapter’s Searching and Sorting Algorithms 824
19.10 Massive Parallelism and Parallel Algorithms 825
19.11 Wrap-Up 825
20 Generic Classes and Methods: A Deeper Look 831
20.1 Introduction 832
20.2 Motivation for Generic Methods 832
20.3 Generic Methods: Implementation and Compile-Time Translation 834
20.4 Additional Compile-Time Translation Issues: Methods That Use a Type
Parameter as the Return Type 837
20.5 Overloading Generic Methods 840
20.6 Generic Classes 841
20.7 Wildcards in Methods That Accept Type Parameters 848
20.8 Wrap-Up 852
21 Custom Generic Data Structures 856
21.1 Introduction 857
21.2 Self-Referential Classes 858
21.3 Dynamic Memory Allocation 858
21.4 Linked Lists 859
21.4.1 Singly Linked Lists 859
21.4.2 Implementing a Generic List Class 860
21.4.3 Generic Classes ListNode and List 863
Contents 19
21.4.4 Class ListTest 863
21.4.5 List Method insertAtFront 865
21.4.6 List Method insertAtBack 866
21.4.7 List Method removeFromFront 866
21.4.8 List Method removeFromBack 867
21.4.9 List Method print 868
21.4.10 Creating Your Own Packages 868
21.5 Stacks 873
21.6 Queues 876
21.7 Trees 878
21.8 Wrap-Up 885
22 JavaFX Graphics and Multimedia 910
22.1 Introduction 911
22.2 Controlling Fonts with Cascading Style Sheets (CSS) 912
22.2.1 CSS That Styles the GUI 912
22.2.2 FXML That Defines the GUI—Introduction to XML Markup 915
22.2.3 Referencing the CSS File from FXML 918
22.2.4 Specifying the VBox’s Style Class 918
22.2.5 Programmatically Loading CSS 918
22.3 Displaying Two-Dimensional Shapes 919
22.3.1 Defining Two-Dimensional Shapes with FXML 919
22.3.2 CSS That Styles the Two-Dimensional Shapes 922
22.4 Polylines, Polygons and Paths 924
22.4.1 GUI and CSS 925
22.4.2 PolyShapesController Class 926
22.5 Transforms 929
22.6 Playing Video with Media, MediaPlayer and MediaViewer 931
22.6.1 VideoPlayer GUI 932
22.6.2 VideoPlayerController Class 934
22.7 Transition Animations 938
22.7.1 TransitionAnimations.fxml 938
22.7.2 TransitionAnimationsController Class 940
22.8 Timeline Animations 944
22.9 Frame-by-Frame Animation with AnimationTimer 947
22.10 Drawing on a Canvas 949
22.11 Three-Dimensional Shapes 954
22.12 Wrap-Up 957
23 Concurrency 973
23.1 Introduction 974
23.2 Thread States and Life Cycle 976
23.2.1 New and Runnable States 977
23.2.2 Waiting State 977
Random documents with unrelated
content Scribd suggests to you:
President of
Washington
College
ROBERT EDWARD LEE
From a portrait painted by Browne, now
in the Westmoreland Club, Richmond,
Virginia
The next morning Lee, surrounded by his sorrowing men, mounted
his horse, Traveler, and rode slowly away to his home in Richmond.
The other Confederate armies surrendered one by one.
After the war General Lee was elected president of
Washington College at Lexington, Virginia, now
Washington and Lee University. He greatly enjoyed
his work of building up the young manhood of the
Dies in 1870
South. He died at Lexington in 1870. A monument
to the memory of this great man has been erected
at Richmond, and another at Lexington.
SUGGESTIONS INTENDED TO HELP THE PUPIL
The Leading Facts. 1. Grant born of parents who were
farmers. Loved to work with horses. 2. Sent to West Point;
was in Mexican War under Generals Taylor and Scott. 3.
Was clerk for his father at Galena. 4. In the Civil War rose
rapidly till made a major-general. 5. Captured Fort
Donelson and Fort Henry. 6. Captured Vicksburg; was
made lieutenant-general, and sent into the Wilderness
after General Lee. 7. Fought a month, then moved around
to Petersburg. 8. Offered Lee terms of surrender. 9. Was
twice made president. 10. Died at Mount McGregor. 11.
Robert E. Lee was born in Virginia and went to school at
Alexandria. 12. Went to West Point, and was in the
Mexican War, where he earned honor and fame. 13. Took
charge at West Point. 14. Followed Virginia when she
seceded, and was given command of the troops defending
Richmond. 15. Won several victories over the North. 16.
Failed at Gettysburg. 17. Fought to save Richmond. 18.
Surrendered to General Grant in spring of 1865. 19.
Became president of Washington College.
Study Questions. 1. Tell the story of Grant until he
reached West Point. 2. What part did Grant take in the
war with Mexico? 3. What did Grant do at Galena when
Lincoln's call came? 4. Tell of his promotion. 5. What
would happen if Vicksburg and other Mississippi River
places were taken? 6. What two victories came on the
Fourth of July, and what did both mean? 7. How did
Grant's victory impress the president? 8. What can you tell
of the "Battle of the Wilderness"? 9. What happened at
Richmond? 10. Picture the scene at Appomattox Court
House. 11. Tell the story of Grant after the Civil War. 12.
Tell of Lee's promotion after leaving West Point. 13. Did
Lee want his state to leave the Union? 14. Was he a
victorious general at first? 15. What happened at
Gettysburg? 16. Tell about Lee defending Richmond. 17.
What did Lee plan to do after Richmond fell? 18. Why did
he not carry out this plan? 19. What position did Lee
accept after the war?
Suggested Readings. Ulysses S. Grant: Burton, Four
American Patriots, 195-254; Brooks, Century Book of
Famous Americans, 181-191; Hart and Stevens, Romance
of the Civil War, 179-183; Hale, Stories of War, 21-29, 74-
91, 92-118, 168-187, 226-264; Bolton, Famous American
Statesmen, 307-360.
Robert E. Lee: Hale, Stories of War, 61-73, 119, 149;
Mabie, Heroes Every Child Should Know, 289-308; Magill,
Stories from Virginia History, 162-172.
(eBook PDF) Java How to Program, Late Objects Global Edition 11th Edition
MEN WHO DETERMINED NEW
POLITICAL POLICIES
RUTHERFORD B. HAYES
175. A Wise and Independent President. In 1822 a baby boy
was born in the old college town of Delaware, Ohio. His parents
named the boy Rutherford B. Hayes. As a youngster he loved his
books and his playmates.
RUTHERFORD B. HAYES
A leader at
college
Becomes a
general
Refuses to
leave his post
to campaign
From a photograph by Pach Bros., New
York City
At an early age he entered Kenyon College, Ohio.
Here he was a leader among his fellows, not only
in college affairs, but in his daily work in the
classroom. He graduated with first honors in his class.
For his after-college work Hayes decided to choose the law, and
graduated from Harvard Law School. He was just beginning to win
success when Lincoln's call to arms aroused the men of the North. It
seemed terrible for northern men and southern men to fight against
each other, but it had to be done to save the Union.
Hayes volunteered and was made a major in
command. By his fine work as an officer in caring
for his men and in bravery on the field of battle, he
won the title of general. While he was still fighting, the people at
home, looking for a high-minded, honorable man for congress,
nominated Hayes.
His supporters sent for him to come home and
canvass for votes. He would not go. He said: "An
officer fit for duty who, at such a time as this,
would abandon his post to electioneer for a seat in
Congress, ought to be scalped." Hayes remained at his post and was
elected by a large majority.
Hayes had become known to all the people of his state and they
wanted him for governor. So friendly was he toward all whether high
or low, so honest was he that three times the people chose him to
be their governor.
In 1876 the Republicans of the nation selected him to be their
candidate for the high office of president. The Democratic candidate
was a man of very high reputation, Samuel J. Tilden of New York. He
was known as a fighter for honesty and against wrongdoing in public
office.
Contest over
the presidency
Generous
toward the
South
A startling
change in
custom
Unfortunately, the politicians aroused bitter feeling
between the North and the South in this campaign.
When it was seen that Hayes was winner by only
one vote, there were threats of "civil war." But luckily Tilden did not
lose his head, and his party, following his advice, accepted the
result.
Hayes decided to take the Union soldiers out of the
South. The radical Republicans opposed this action,
but the majority of the people in the North favored
it. The southern people were happy, because now
they might manage their elections to suit themselves.
President Hayes also placed a southern man in his cabinet, and this,
too, helped along the good feeling between the North and the
South.
We can see now that the return of good feeling between the North
and the South was necessary, but it was not so easily seen then.
Now we can say that President Hayes was a noble and far-seeing
statesman when he offered the "olive branch" to the South.
Lucy Hayes, his wife, was a brave woman. She
startled society at Washington and in the country
at large by issuing a decree that no strong drink
should be used in the White House. The
temperance people were happy, but others were not, especially the
ministers of foreign countries who had always been in the habit of
using wine on social occasions. A great cry was raised throughout
the country, but Lucy Webb Hayes stood her ground.
JAMES A. GARFIELD AND CHESTER A. ARTHUR
JAMES A. GARFIELD
After a photograph by E. Bierstadt
176. The Towpath that Led to the Presidency. Like Lincoln, the
second of our "martyr Presidents" started life in a log cabin. Garfield
was born near Cleveland, Ohio (1831). His parents were poor and
his father died while Garfield was yet an infant. Garfield's mother
Determined to
have an
education
War, Congress,
and the
Presidency
was brave and held her little family together. The children did not
have much chance to go to school. Life to them was a hard struggle.
When James reached the age of fifteen, he began driving mules on
the towpath of a canal running from Cleveland to Portsmouth. This
was the time when canal boats carried both freight and passengers.
The towpath was a hard "school," but had many good lessons for a
boy wise enough to keep out of mischief.
He had his heart set on an education. He went to
school long enough to be able to teach school. He
shared his earnings with his mother. Teaching only
sharpened his appetite for an education. For a time
he went to Hiram College and afterward became a teacher there. He
loved Hiram College because it was supported by the Church of the
Disciples, of which he was a member. He finished his education at
Williams College.
When Lincoln called for men for the war, Garfield, like thousands of
others, volunteered. He became an officer and did his work so well
that he was promoted to be major general. Like Hayes, he was
elected to Congress while in the army, fighting its battles. Again and
again, the people of his district sent him to Congress, and finally in
1880 the legislature of his native state made him a United States
senator.
Garfield was a wonderful orator. Before the
Republicans, gathered in Chicago, he placed the
name of John Sherman in nomination for the
presidency. So great was this speech that the
convention turned from all the men who were before it, and
nominated Garfield himself.
Garfield won the presidency before he had a chance to take his seat
as United States senator. After delivering his inaugural address to
the vast crowd gathered, he turned and kissed his mother.
The Republicans had promised to make new rules about men
appointed to office. They declared that men should not hold office
Civil service
reform
just because they had worked for the party in power, but that they
should pass an examination to find out whether or not they were fit
for the position.
While Garfield was leaving Washington to attend the Fourth of July
celebration at Williams College, he was shot by a half-crazy,
disappointed office seeker. He lived until September. Few young
people can now understand how the American people felt during this
time. They learned to hate the "spoils system." Garfield's death
sealed its fate.
177. Arthur Becomes President. Chester A.
Arthur was thought to be a "politician" merely, but
he proved to be a good president. He began to
build up a strong navy and started the movement for the reform of
the civil service.
CHESTER A. ARTHUR
From a photograph by Sarony
Since the days of the Civil War, we had been too busy with affairs at
home to think much about the need of a navy. But beginning with
President Arthur's administration we have increased its size from
time to time, until during the war with Spain, our people came to
feel the navy's value.
Under Arthur the spoils system received its first deadly blow when
Congress passed and Arthur signed a bill establishing the merit
system. By this system, men are appointed to office only after they
have proved their fitness by an examination. Under it men cannot be
turned out of office except for just cause.
Early life
GROVER CLEVELAND
178. A Man Who Was Twice President. Grover
Cleveland saw the light of day in the old state of
New Jersey in 1837. While he was yet a boy his
parents moved to central New York. Here he received a common
school education. He was a good pupil and made friends with boys
who loved honesty and fair play. His parents were poor and could
not send him to college. He was always sorry for this and tried to
make up for it by hard study. The lives of men great in history and
literature were what he liked best to read.
Lawyer, mayor,
and governor
GROVER CLEVELAND
From a photograph by Bell
After going to Buffalo, young Cleveland entered upon the study of
law. He studied long upon the fine points of the law. In time he
became one of the ablest lawyers, not only in Buffalo, but in the
State of New York. The fact that young Cleveland was chosen sheriff
of Erie County shows that a great many people already looked upon
him as a courageous man.
When Buffalo needed a mayor who was not afraid
to do his duty, the people elected this man who
had been a good sheriff.
Runs against
Blaine
The panic of
1893
The great
railroad strike
The people of the State of New York wanted a man of the Cleveland
type for governor. He carried the state by a great majority. He was a
great governor as he had been a great mayor. He was honest and
straightforward, and treated all men alike. Long before his time as
governor was up, the people began to talk of him for president.
Cleveland ran against a widely known and popular
man, James G. Blaine of Maine. But the
Republicans split and Cleveland won. The
Democrats were happy over the result, for this was the first time
they had elected a president since 1856.
The Republicans had kept a high tariff ever since the Civil War. The
result was that our treasury at Washington was full of money.
Cleveland sent a message to Congress asking that the tariff be cut
down, but the high-tariff Democrats joined the Republicans in
supporting it.
Cleveland had made many enemies in his own party by refusing to
appoint unfit men to office. When, therefore, he ran for president
again in 1888, he was beaten by Senator Harrison of Indiana.
But four years later, in 1892, he defeated Harrison and again
became president.
179. The Panic of 1893. Cleveland had hardly
taken his seat as President when hard times struck
the country. Business men and laborers suffered
greatly. They could not pay their debts. Men, women, and children
suffered for want of bread.
The Pullman Car Company of Chicago cut down the
wages of its workmen. The men called a strike
which finally extended over half the states of the
Union.
Chicago was the center of the strike. Hundreds of cars were burned
and lives were threatened. It was impossible to carry the United
States mail or freight from one state to another. Grover Cleveland
ordered United States soldiers to Chicago to keep the mails going
and the freight running. This broke the back of the strike. Cleveland
had shown how to settle strikes in a new way.
Cleveland served twice as President and after his second term of
office he moved to Princeton, New Jersey, the seat of Princeton
University. Here he became famous for his lectures given before the
student body.
BENJAMIN HARRISON
BENJAMIN HARRISON
From a photograph by L. Alman
180. A General Who Became President. Early in our national
history it had happened that the son of a President of the United
States had also become President. In 1833 a boy was born in Ohio,
the grandson of a President, who was also to gain this high position.
Enters the army
Active in
politics
A picturesque
campaign
His grandfather was William Henry Harrison, who was elected
President in the stirring campaign of 1840. His parents named him
Benjamin.
Young Harrison, a happy and well-born boy, received his education
in the public schools. He entered Miami University at an early age
and graduated at eighteen.
Harrison, like so many of our other presidents, studied law. He was
very soon admitted to the bar, and in 1854 he went to live in the
Hoosier State at Indianapolis.
He answered the call to arms. He was made a
lieutenant, but had hardly learned his duties before
he was promoted to be captain of a company of
one hundred men. Hardly a month passed before an order came
making him a colonel of a regiment of a thousand men. He led this
regiment until the last days of the war, and the boys were proud of
"Colonel Ben."
For personal bravery and for skill in handling his men in one of the
battles in Georgia, he was made major general.
After the war Harrison returned to the law. In
political campaigns he was much sought after to
speak in all parts of the state.
He did not accept office until he was elected United States senator in
1881. Senator Harrison was nominated for the presidency in 1888.
He set the example of making speeches "on his front porch" to
admiring crowds who came from different states.
In this campaign the Democrats pointed to
Harrison as a man who wore his "grandfather's
hat." The Republicans made this campaign like that
of 1840. There was great enthusiasm, big wagons carrying log
cabins with raccoons and barrels of hard cider, great balls rolling on,
and happy songs. Tippecanoe clubs were formed in all parts of the
country. The result was the election of Harrison.
Pensions and
the tariff
Under President Harrison a tariff law was passed
with a reciprocity agreement. By this arrangement,
the United States agreed to reduce its tariff if other
nations would reduce theirs. President Harrison had a warm spot in
his heart for the old soldiers, and he signed with pleasure a new
pension law.
The farmers and the silver men of the West were becoming
dissatisfied with the action of Congress. In 1890 their forces elected
several new Congressmen, and in the next year formed the People's
party. Most of the votes of this party were drawn from the
Republican side, hence in the next campaign Harrison was defeated
by Cleveland.
SUGGESTIONS INTENDED TO HELP THE PUPIL
The Leading Facts. 1. Hayes studied law, and served in
the Civil War. 2. He was elected to Congress while still in
the field. 3. He received only one more vote than Tilden
for President. 4. He was wise and fair in his treatment of
the South. 5. Garfield was a poor boy who had to work
hard for an education. 6. He was a war veteran and was
elected senator before becoming President. 7. His
remarkable ability as an orator caused him to be
nominated for the presidency. 8. His assassination helped
to bring civil service reform. 9. Arthur when President,
worked for a larger navy. 10. He supported civil service
against the spoils system. 11. Cleveland, after being
mayor of Buffalo and governor of New York, was elected
President twice, though not in succession. 12. A severe
panic occurred while he was President. 13. Harrison
studied law, and became a general during the Civil War.
14. His election was like that of his grandfather, William
Henry Harrison. 15. Changes in the tariff and in pension
laws took place during his presidency. 16. At the following
election the farmers and those favoring silver money
combined in the Populist party, reducing the Republican
vote and causing the election of Cleveland.
Study Questions. 1. Tell something of Hayes' early life.
2. How did he come to be chosen Congressman? 3. What
was unusual about his election to the presidency? 4. How
was his election accepted by the country? 5. What kind of
a President did he make? 6. What can you tell of Garfield's
youth? 7. What positions did he hold before becoming
President? 8. What brought about his nomination? 9.
What reform did the nation demand after Garfield's
assassination? 10. What two things did Arthur work for?
11. What positions did Cleveland hold? 12. Name two
important things that happened while he was President.
13. Tell something of Harrison's career and election. 14.
What was done about the tariff and pensions during his
presidency? 15. Why was Harrison defeated by Cleveland
in the next election?
Suggested Readings. Higginson, History of the United
States, 330-347; Guerber, Story of the Great Republic,
281-285, 288-293.
(eBook PDF) Java How to Program, Late Objects Global Edition 11th Edition
THE BEGINNING OF EXPANSION
ABROAD
WILLIAM McKINLEY AND THE SPANISH-
AMERICAN WAR
WILLIAM McKINLEY
From a photograph by Courtney,
taken at Canton, Ohio
William
McKinley, 1843
Teaches school
Enlists to fight
for the Union
Wins praise and
promotion
Studies law
Becomes a
successful
lawyer and
speaker
In Congress
Elected
president
181. William McKinley. William McKinley was
born in Ohio in 1843. As a boy his chief delight was
to roam the fields and woods surrounding Niles, his
home town, or to fish in the fine streams near by.
When he was about nine years old his parents
moved to Poland, Ohio, where there were good schools for children.
McKinley studied hard, and at seventeen years of age entered
Allegheny College at Meadville, Pennsylvania. But his health had
never been very good and he fell ill from hard study. He returned to
Poland, and there a little later he taught school.
In 1861 Lincoln's call for troops to save the Union
fired the whole North with patriotism. McKinley,
though then only eighteen years of age, enlisted at
once. Under fire at Antietam and in later battles of
the war, he won praise and promotion for his heroic
deeds. The active army life was good for him, and
when the war was over he was a strong and healthy man. He
enlisted as a private and came out as a major. All his promotions
were for merit and bravery.
He returned to Poland and took up the study of the
law. But his means were small and he had a hard
struggle. In 1867 McKinley was admitted to the bar
and opened an office in Canton, Ohio.
Like many another young lawyer he had numerous
difficulties and disappointments, but he worked
hard and in time became a successful lawyer. He
was a good speaker and soon was much in
demand in political campaigns.
The people admired him. They felt that he could be
trusted. They sent him, for seven terms, to
represent them in Congress at Washington, and
twice they made him governor of Ohio. In 1896 he
was elected president of the United States.
The Cubans
revolt
Americans
182. Spanish Persecution in Cuba. Since the
earliest days of Spanish rule, Cuba had been
discontented and had engaged in frequent wars
with Spain because of heavy taxation and bad government. Again
and again the Cubans revolted, but they were not strong enough to
succeed and Spanish oppression continued. In 1895 the people rose
in a last desperate effort to free themselves. To crush them Spain
sent a large army under a cruel general. Large numbers of unarmed
Cubans—men, women, and children—were gathered into camps
guarded by Spanish soldiers and cut off from food and other
supplies. Thousands died of starvation and disease.
HOW THE CUBANS FOUGHT
Lying in ambush for the advancing column of the
enemy
These and other harsh things done in an attempt
to break the spirit of the Cubans filled the
aroused
Red Cross
Society goes to
Cuba
American people with bitter indignation. On the
recommendation of President McKinley, Congress
voted fifty thousand dollars for relief work. Money,
by private contribution, also flowed in from all parts
of the country. The Red Cross Society, led by Clara
Barton, hastened to the island to relieve the awful conditions of
hunger and disease.
GEORGE DEWEY
From a photograph taken in 1900 by
Francis B. Johnston, Washington, D.C.
Battleship
"Maine" blown
up
War declared
Dewey destroys
the Spanish
fleet
California
volunteers lead
in numbers
The American people were aroused. They demanded that the United
States interfere in behalf of the suffering Cubans, who were fighting
to be free. They were eager to take up arms for freedom and
humanity.
Indignation was brought to its highest pitch when,
on February 15, 1898, the United States battleship
Maine was sunk in Havana Harbor, two hundred
sixty of the crew perishing. What was the cause of
the explosion has never been found out, but Americans then
believed it to be the work of the Spaniards.
In April the United States demanded that the
Spanish troops be taken from Cuba and the Cubans
be given their independence. Spain was given
three days in which to reply. She immediately declared war against
the United States.
183. A War for the Sake of Humanity. The war
had hardly begun before Admiral George Dewey
destroyed the Spanish fleet and pounded to pieces
the shore batteries in Manila Bay, Philippine
Islands. Dewey, with his fleet, sailed under orders from Hong-kong,
China, entered the bay, and did his work without the loss of a man.
This deed made him the naval hero of the war.
Thousands of men, North and South, rallied to the
call of President McKinley. The states of the far
West responded with noble enthusiasm. California,
largest in population and wealth, led in the number
of its volunteers.
"Rough Riders"
win fame
SCENE OF THE SPANISH WAR IN
THE PHILIPPINES
The land forces in Cuba were under the command
of General Shafter. They stormed El Caney and San
Juan and marched on Santiago. But the "Rough
Riders," a regiment raised from the mountains and plains, attracted
the most attention. Colonel Leonard Wood had command of them,
aided by Theodore Roosevelt. When Wood was made a general,
Roosevelt became their colonel, and fought through the war with
them.
A large fleet sent from Spain under Admiral Cervera had kept out of
the way of the American fleet under Rear-Admiral Sampson and
Spanish fleet in
Santiago
Harbor
Cervera's fleet
destroyed
Treaty of peace
signed
The Philippines
bought for
twenty million
dollars
Commodore Schley and was now hidden in
Santiago Harbor. When the Americans captured El
Caney and San Juan, the Spanish admiral decided
that Santiago would soon be in American hands. To
escape being taken prisoner he made a bold dash from the harbor.
THE BATTLE OF MANILA BAY
The American naval forces were on the watch, and
soon the entire Spanish fleet was destroyed or
captured—July 3, 1898.
The occupation by the Americans of the city of
Manila, in the Philippines, in August (1898),
brought peace proposals from Spain. These were
accepted, the treaty being signed on the tenth of December.
This war was fought for the sake of humanity and
freedom and not for gain or glory. The United
States had taken the side of an oppressed people
struggling for independence but she did not claim
these countries as the spoils of war. She paid Spain
twenty million dollars in gold for the Philippines, and at once set to
work to establish schools, build good roads, help the farmers, and
improve living conditions by making the government more stable
and humane.
Hawaiian
Islands
annexed
Cuba a republic
Conditions in
Cuba greatly
improved
United States a
world power
It had long been felt, especially by the people of
the Pacific States, that for both commercial and
military reasons the Hawaiian Islands should
belong to us. These islands—eight in all—were
annexed in 1898.
Steps were taken at once to give the people of
Cuba a government of their own. The island was
made a republic. The constitution, drawn up
somewhat like our own, was adopted by the people
of Cuba, February 21, 1902. The United States did
much to help the people before it withdrew from
the island in 1902 and left the Cubans to rule
themselves. Conditions have rapidly improved. In
1894, under Spanish rule, there were only about
900 public schools, and, even including the 700 private schools, only
about 60,000 pupils were on the rolls. Six years later, under
American rule, there were 3,550 public schools, with 172,000 pupils
enrolled. By the conduct of their government the Cubans are
justifying the confidence the American people had in them.
THE BATTLE OF SANTIAGO
As a result of the war Guam and Porto Rico also became American
possessions. This was the beginning of American territorial
McKinley shot
by an anarchist
in 1901
expansion. The United States took its place among the great world
powers, and has since played an important part in the affairs of
nations.
184. McKinley Assassinated. President McKinley
did not live to see the results of self-government in
Cuba. Shortly after his election to a second term as
president, he was shot by an anarchist, while the
guest of the Pan-American Exposition at Buffalo in September, 1901.
After a week of patient suffering, watched with painful anxiety by
the people, William McKinley, our third martyr president, passed
away.
SUGGESTIONS INTENDED TO HELP THE PUPIL
The Leading Facts. 1. William McKinley was born in
Ohio. 2. He went to college at Meadville, Pennsylvania,
and afterwards taught school. 3. Enlisted as a private in
1861 and won praise and promotion for bravery in fighting
for the Union. 4. After the war he studied law and opened
an office in Canton, Ohio. 5. Was a good speaker and was
sent to Congress at Washington for seven terms. 6. Twice
governor of Ohio, he was elected president of the United
States in 1896. 7. The Cubans had revolted many times
against Spanish oppression and now rose again. 8. The
Americans sympathized with the suffering Cubans;
Congress voted fifty thousand dollars for relief work. 9.
The United States battleship Maine blown up in Havana
Harbor. 10. Spain declared war against the United States.
11. Admiral George Dewey destroyed the Spanish fleet at
Manila in the Philippine Islands. 12. American forces,
among them the Rough Riders, attacked the Spanish in
Cuba. 13. American fleet destroyed the Spanish fleet at
Santiago. 14. Peace proposals came from Spain and the
treaty of peace was signed in December, 1898. 15. The
United States bought the Philippines from Spain, the
Hawaiian Islands were annexed, and Cuba became a
republic. 16. Guam and Porto Rico also became American
possessions. 17. Conditions in former Spanish possessions
greatly improved. 18. McKinley was assassinated by an
anarchist while he was the guest of the Pan-American
Exposition at Buffalo, in September, 1901 and died soon
after.
Study Questions. 1. Describe McKinley's boyhood
surroundings and what he liked to do. 2. What made him
fall ill? 3. How did he answer Lincoln's call for troops? 4.
What effect did army life have on his health? 5. What did
he do after the war? 6. To what public office was he
elected? 7. Why did the Cubans revolt against Spain? 8.
How did the Spaniards attempt to crush the revolt? 9.
What did the Americans do to relieve the suffering of the
Cubans? 10. What did they want to do? 11. How did the
sinking of the Maine affect Americans? 12. What did the
United States demand of Spain? 13. Describe Dewey's
action at Manila. 14. What state led in the number of
volunteers? 15. What were the "Rough Riders"? 16. What
happened at Santiago? 17. What finally brought peace
proposals from Spain? 18. Why had the war been fought?
19. What did the Americans do in the Philippines? 20.
What other islands came into American possession? 21.
What happened in Cuba? 22. When and in what city was
President McKinley assassinated?
Suggested Readings. Stratemeyer, American Boy's Life
of William McKinley; Morris, The War with Spain, 150-169,
180-214, 267-285; Barrett, Admiral George Dewey, 55-
152, 230-251; Ross, Heroes of Our War with Spain.
(eBook PDF) Java How to Program, Late Objects Global Edition 11th Edition
THE MAN WHO WAS THE
CHAMPION OF DEMOCRACY
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!
ebookluna.com

More Related Content

PDF
Java How To Program Early Objects Eleventh Edition Deitel Harvey M Deitel
PDF
Essential Java For Scientists And Engineers 1st Brian D Hahn
PDF
Download full ebook of Java Cookbook Ian F Darwin Darwin Ian F instant downlo...
PDF
Introduction to Programming with Java 3rd Edition John Dean
PDF
Mastering Java A Beginners Guide Divya Sachdeva Natalya Ustukpayeva
PDF
Java Complete Reference Fifth Edition
PDF
(eBook PDF) Introduction to Programming with Java: A Problem Solving Approach...
PDF
Learning Java An Introduction to Real World Programming with Java Marc Loy
Java How To Program Early Objects Eleventh Edition Deitel Harvey M Deitel
Essential Java For Scientists And Engineers 1st Brian D Hahn
Download full ebook of Java Cookbook Ian F Darwin Darwin Ian F instant downlo...
Introduction to Programming with Java 3rd Edition John Dean
Mastering Java A Beginners Guide Divya Sachdeva Natalya Ustukpayeva
Java Complete Reference Fifth Edition
(eBook PDF) Introduction to Programming with Java: A Problem Solving Approach...
Learning Java An Introduction to Real World Programming with Java Marc Loy

Similar to (eBook PDF) Java How to Program, Late Objects Global Edition 11th Edition (20)

PDF
Mastering Java: A Beginner's Guide 1st Edition Sufyan Bin Uzayr
PDF
(eBook PDF) Starting Out with Java: From Control Structures through Objects, ...
PDF
Learning Java An Introduction to Real World Programming with Java Marc Loy
PDF
(eTextbook PDF) for Starting Out with Java: From Control Structures through O...
PDF
Download full ebook of Programming With Java Edet Theophilus instant download...
PDF
(eBook PDF) Introduction to Programming with Java: A Problem Solving Approach...
PDF
Java Illuminated An Active Learning Approach 5th Julie Anderson
PDF
Learning Java 4th Edition Patrick Niemeyer Daniel Leuck
PDF
Pearson.Java.How.To.Program.late.objects.10th.Edition.www.EBooksWorld.ir.pdf
PDF
(eBook PDF) Introduction to Programming with Java: A Problem Solving Approach...
PDF
Objectoriented Programming And Java 2nd Ed Danny C C Poo Derek Beng Kee Kiong...
PDF
Java The Complete Reference Ninth Edition Herbert Schildt
PDF
Mastering Java: A Beginner's Guide 1st Edition Sufyan Bin Uzayr
PDF
Learn java in one day and learn it well 2016 jamie chan
PDF
Java Programming.pdf
PDF
Core Java Vol 1 2 For The Impatient And Effective Pack 12th Ed Cay S Horstmann
PDF
[FREE PDF sample] Object Oriented Programming and Java Second Edition Danny P...
PDF
Data structures and_algorithms_in_java
PPT
CSL101_Ch1.ppt
Mastering Java: A Beginner's Guide 1st Edition Sufyan Bin Uzayr
(eBook PDF) Starting Out with Java: From Control Structures through Objects, ...
Learning Java An Introduction to Real World Programming with Java Marc Loy
(eTextbook PDF) for Starting Out with Java: From Control Structures through O...
Download full ebook of Programming With Java Edet Theophilus instant download...
(eBook PDF) Introduction to Programming with Java: A Problem Solving Approach...
Java Illuminated An Active Learning Approach 5th Julie Anderson
Learning Java 4th Edition Patrick Niemeyer Daniel Leuck
Pearson.Java.How.To.Program.late.objects.10th.Edition.www.EBooksWorld.ir.pdf
(eBook PDF) Introduction to Programming with Java: A Problem Solving Approach...
Objectoriented Programming And Java 2nd Ed Danny C C Poo Derek Beng Kee Kiong...
Java The Complete Reference Ninth Edition Herbert Schildt
Mastering Java: A Beginner's Guide 1st Edition Sufyan Bin Uzayr
Learn java in one day and learn it well 2016 jamie chan
Java Programming.pdf
Core Java Vol 1 2 For The Impatient And Effective Pack 12th Ed Cay S Horstmann
[FREE PDF sample] Object Oriented Programming and Java Second Edition Danny P...
Data structures and_algorithms_in_java
CSL101_Ch1.ppt
Ad

Recently uploaded (20)

PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
GDM (1) (1).pptx small presentation for students
PDF
Classroom Observation Tools for Teachers
PPTX
Lesson notes of climatology university.
PDF
RMMM.pdf make it easy to upload and study
PDF
Sports Quiz easy sports quiz sports quiz
PPTX
Institutional Correction lecture only . . .
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
Insiders guide to clinical Medicine.pdf
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
Pharma ospi slides which help in ospi learning
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPTX
Cell Types and Its function , kingdom of life
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
VCE English Exam - Section C Student Revision Booklet
human mycosis Human fungal infections are called human mycosis..pptx
STATICS OF THE RIGID BODIES Hibbelers.pdf
GDM (1) (1).pptx small presentation for students
Classroom Observation Tools for Teachers
Lesson notes of climatology university.
RMMM.pdf make it easy to upload and study
Sports Quiz easy sports quiz sports quiz
Institutional Correction lecture only . . .
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Insiders guide to clinical Medicine.pdf
Renaissance Architecture: A Journey from Faith to Humanism
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Pharma ospi slides which help in ospi learning
Module 4: Burden of Disease Tutorial Slides S2 2025
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Cell Types and Its function , kingdom of life
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
VCE English Exam - Section C Student Revision Booklet
Ad

(eBook PDF) Java How to Program, Late Objects Global Edition 11th Edition

  • 1. Read Anytime Anywhere Easy Ebook Downloads at ebookluna.com (eBook PDF) Java How to Program, Late Objects Global Edition 11th Edition https://ebookluna.com/product/ebook-pdf-java-how-to-program- late-objects-global-edition-11th-edition/ OR CLICK HERE DOWLOAD EBOOK Visit and Get More Ebook Downloads Instantly at https://ebookluna.com
  • 2. Instant digital products (PDF, ePub, MOBI) available Download now and explore formats that suit you... (eBook PDF) Java How To Program (Early Objects) 10th https://ebookluna.com/product/ebook-pdf-java-how-to-program-early- objects-10th/ ebookluna.com (eBook PDF) Java How to Program, Early Objects 11th Edition by Paul J. Deitel https://ebookluna.com/product/ebook-pdf-java-how-to-program-early- objects-11th-edition-by-paul-j-deitel/ ebookluna.com (eBook PDF) Java Concepts: Late Objects, 3rd Edition https://ebookluna.com/product/ebook-pdf-java-concepts-late- objects-3rd-edition/ ebookluna.com (eBook PDF) Big Java Late Objects 2nd Edition https://ebookluna.com/product/ebook-pdf-big-java-late-objects-2nd- edition/ ebookluna.com
  • 3. C++ How to Program: An Objects-Natural Approach, 11e 11th Edition Paul Deitel - eBook PDF https://ebookluna.com/download/c-how-to-program-an-objects-natural- approach-11e-ebook-pdf/ ebookluna.com C++ How to Program Early Objects Version 9th Edition (eBook PDF) https://ebookluna.com/product/c-how-to-program-early-objects- version-9th-edition-ebook-pdf/ ebookluna.com C How to Program, 9th Global Edition Deitel Paul - eBook PDF https://ebookluna.com/download/c-how-to-program-9th-global-edition- ebook-pdf/ ebookluna.com (eBook PDF) Big C++: Late Objects 3rd Edition https://ebookluna.com/product/ebook-pdf-big-c-late-objects-3rd- edition/ ebookluna.com (eBook PDF) Brief C++: Late Objects, 3rd Edition https://ebookluna.com/product/ebook-pdf-brief-c-late-objects-3rd- edition/ ebookluna.com
  • 6. Trademarks DEITEL and the double-thumbs-up bug are registered trademarks of Deitel and Associates, Inc. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners. Microsoft and/or its respective suppliers make no representations about the suitability of the information contained in the documents and related graphics published as part of the services for any purpose. All such documents and related graphics are provided “as is” without warranty of any kind. Microsoft and/ or its respective suppliers hereby disclaim all warranties and conditions with regard to this information, including all warranties and conditions of merchantability, whether express, implied or statutory, fitness for a particular purpose, title and non-infringement. In no event shall Microsoft and/or its respective sup- pliers be liable for any special, indirect or consequential damages or any damages whatsoever resulting from loss of use, data or profits, whether in an action of contract, negligence or other tortious action, arising out of or in connection with the use or performance of information available from the services. The documents and related graphics contained herein could include technical inaccuracies or typograph- ical errors. Changes are periodically added to the information herein. Microsoft and/or its respective sup- pliers may make improvements and/or changes in the product(s) and/or the program(s) described herein at any time. Partial screen shots may be viewed in full within the software version specified. Microsoft® and Windows® are registered trademarks of the Microsoft Corporation in the U.S.A. and other countries. Screen shots and icons reprinted with permission from the Microsoft Corporation. This book is not sponsored or endorsed by or affiliated with the Microsoft Corporation. UNIX is a registered trademark of The Open Group. Apache is a trademark of The Apache Software Foundation. CSS and XML are registered trademarks of the World Wide Web Consortium. Firefox is a registered trademark of the Mozilla Foundation. Google is a trademark of Google, Inc. Mac and macOS are trademarks of Apple Inc., registered in the U.S. and other countries. Linux is a registered trademark of Linus Torvalds. All trademarks are property of their respective owners. Throughout this book, trademarks are used. Rather than put a trademark symbol in every occurrence of a trademarked name, we state that we are using the names in an editorial fashion only and to the benefit of the trademark owner, with no intention of infringement of the trademark.
  • 7. The online chapters and appendices listed at the end of this Table of Contents are located on the book’s Companion Website (http://www.pearsonglobaleditions.com)—see the inside front cover of your book for details. Foreword 25 Preface 27 Before You Begin 47 1 Introduction to Computers, the Internet and Java 53 1.1 Introduction 54 1.2 Hardware and Software 56 1.2.1 Moore’s Law 56 1.2.2 Computer Organization 57 1.3 Data Hierarchy 59 1.4 Machine Languages, Assembly Languages and High-Level Languages 61 1.5 Basic Introduction to Object Terminology 62 1.5.1 Automobile as an Object 63 1.5.2 Methods and Classes 63 1.5.3 Instantiation 63 1.5.4 Reuse 63 1.5.5 Messages and Method Calls 64 1.5.6 Attributes and Instance Variables 64 1.5.7 Encapsulation and Information Hiding 64 1.5.8 Inheritance 64 1.5.9 Interfaces 65 1.5.10 Object-Oriented Analysis and Design (OOAD) 65 1.5.11 The UML (Unified Modeling Language) 65 1.6 Operating Systems 66 1.6.1 Windows—A Proprietary Operating System 66 1.6.2 Linux—An Open-Source Operating System 66 1.6.3 Apple’s macOS and Apple’s iOS for iPhone®, iPad® and iPod Touch® Devices 67 1.6.4 Google’s Android 67 Contents
  • 8. 8 Contents 1.7 Programming Languages 68 1.8 Java 70 1.9 A Typical Java Development Environment 71 1.10 Test-Driving a Java Application 74 1.11 Internet and World Wide Web 78 1.11.1 Internet: A Network of Networks 79 1.11.2 World Wide Web: Making the Internet User-Friendly 79 1.11.3 Web Services and Mashups 79 1.11.4 Internet of Things 80 1.12 Software Technologies 81 1.13 Getting Your Questions Answered 83 2 Introduction to Java Applications; Input/Output and Operators 87 2.1 Introduction 88 2.2 Your First Program in Java: Printing a Line of Text 88 2.2.1 Compiling the Application 92 2.2.2 Executing the Application 93 2.3 Modifying Your First Java Program 94 2.4 Displaying Text with printf 96 2.5 Another Application: Adding Integers 97 2.5.1 import Declarations 98 2.5.2 Declaring and Creating a Scanner to Obtain User Input from the Keyboard 98 2.5.3 Prompting the User for Input 99 2.5.4 Declaring a Variable to Store an Integer and Obtaining an Integer from the Keyboard 99 2.5.5 Obtaining a Second Integer 100 2.5.6 Using Variables in a Calculation 100 2.5.7 Displaying the Calculation Result 100 2.5.8 Java API Documentation 101 2.5.9 Declaring and Initializing Variables in Separate Statements 101 2.6 Memory Concepts 101 2.7 Arithmetic 102 2.8 Decision Making: Equality and Relational Operators 106 2.9 Wrap-Up 109 3 Control Statements: Part 1; Assignment, ++ and -- Operators 120 3.1 Introduction 121 3.2 Algorithms 121 3.3 Pseudocode 122 3.4 Control Structures 122 3.4.1 Sequence Structure in Java 123
  • 9. Contents 9 3.4.2 Selection Statements in Java 124 3.4.3 Iteration Statements in Java 124 3.4.4 Summary of Control Statements in Java 124 3.5 if Single-Selection Statement 125 3.6 if…else Double-Selection Statement 126 3.6.1 Nested if…else Statements 127 3.6.2 Dangling-else Problem 128 3.6.3 Blocks 128 3.6.4 Conditional Operator (?:) 129 3.7 while Iteration Statement 129 3.8 Formulating Algorithms: Counter-Controlled Iteration 131 3.9 Formulating Algorithms: Sentinel-Controlled Iteration 135 3.10 Formulating Algorithms: Nested Control Statements 142 3.11 Compound Assignment Operators 146 3.12 Increment and Decrement Operators 147 3.13 Primitive Types 150 3.14 Wrap-Up 150 4 Control Statements: Part 2; Logical Operators 164 4.1 Introduction 165 4.2 Essentials of Counter-Controlled Iteration 165 4.3 for Iteration Statement 166 4.4 Examples Using the for Statement 170 4.4.1 Application: Summing the Even Integers from 2 to 20 171 4.4.2 Application: Compound-Interest Calculations 172 4.5 do…while Iteration Statement 175 4.6 switch Multiple-Selection Statement 176 4.7 break and continue Statements 182 4.7.1 break Statement 182 4.7.2 continue Statement 182 4.8 Logical Operators 183 4.8.1 Conditional AND (&&) Operator 184 4.8.2 Conditional OR (||) Operator 184 4.8.3 Short-Circuit Evaluation of Complex Conditions 185 4.8.4 Boolean Logical AND (&) and Boolean Logical Inclusive OR (|) Operators 185 4.8.5 Boolean Logical Exclusive OR (^) 186 4.8.6 Logical Negation (!) Operator 186 4.8.7 Logical Operators Example 187 4.9 Structured-Programming Summary 189 4.10 Wrap-Up 194 5 Methods 204 5.1 Introduction 205
  • 10. 10 Contents 5.2 Program Units in Java 205 5.3 static Methods, static Variables and Class Math 207 5.4 Declaring Methods 209 5.5 Notes on Declaring and Using Methods 213 5.6 Method-Call Stack and Activation Records 214 5.6.1 Method-Call Stack 214 5.6.2 Stack Frames 214 5.6.3 Local Variables and Stack Frames 215 5.6.4 Stack Overflow 215 5.7 Argument Promotion and Casting 215 5.8 Java API Packages 216 5.9 Case Study: Secure Random-Number Generation 218 5.10 Case Study: A Game of Chance; Introducing enums 223 5.11 Scope of Declarations 227 5.12 Method Overloading 230 5.12.1 Declaring Overloaded Methods 230 5.12.2 Distinguishing Between Overloaded Methods 231 5.12.3 Return Types of Overloaded Methods 231 5.13 Wrap-Up 232 6 Arrays and ArrayLists 245 6.1 Introduction 246 6.2 Primitive Types vs. Reference Types 247 6.3 Arrays 247 6.4 Declaring and Creating Arrays 249 6.5 Examples Using Arrays 250 6.5.1 Creating and Initializing an Array 250 6.5.2 Using an Array Initializer 251 6.5.3 Calculating the Values to Store in an Array 252 6.5.4 Summing the Elements of an Array 253 6.5.5 Using Bar Charts to Display Array Data Graphically 254 6.5.6 Using the Elements of an Array as Counters 256 6.5.7 Using Arrays to Analyze Survey Results 257 6.6 Exception Handling: Processing the Incorrect Response 259 6.6.1 The try Statement 259 6.6.2 Executing the catch Block 259 6.6.3 toString Method of the Exception Parameter 260 6.7 Enhanced for Statement 260 6.8 Passing Arrays to Methods 261 6.9 Pass-By-Value vs. Pass-By-Reference 264 6.10 Multidimensional Arrays 264 6.10.1 Arrays of One-Dimensional Arrays 265 6.10.2 Two-Dimensional Arrays with Rows of Different Lengths 265 6.10.3 Creating Two-Dimensional Arrays with Array-Creation Expressions 266
  • 11. Contents 11 6.10.4 Two-Dimensional Array Example: Displaying Element Values 266 6.10.5 Common Multidimensional-Array Manipulations Performed with for Statements 267 6.11 Variable-Length Argument Lists 268 6.12 Using Command-Line Arguments 269 6.13 Class Arrays 271 6.14 Introduction to Collections and Class ArrayList 274 6.15 Wrap-Up 278 7 Introduction to Classes and Objects 298 7.1 Introduction 299 7.2 Instance Variables, set Methods and get Methods 300 7.2.1 Account Class with an Instance Variable, and set and get Methods 300 7.2.2 AccountTest Class That Creates and Uses an Object of Class Account 302 7.2.3 Compiling and Executing an App with Multiple Classes 305 7.2.4 Account UML Class Diagram 305 7.2.5 Additional Notes on Class AccountTest 306 7.2.6 Software Engineering with private Instance Variables and public set and get Methods 307 7.3 Default and Explicit Initialization for Instance Variables 308 7.4 Account Class: Initializing Objects with Constructors 309 7.4.1 Declaring an Account Constructor for Custom Object Initialization 309 7.4.2 Class AccountTest: Initializing Account Objects When They’re Created 310 7.5 Account Class with a Balance 312 7.5.1 Account Class with a balance Instance Variable of Type double 312 7.5.2 AccountTest Class to Use Class Account 313 7.6 Case Study: Card Shuffling and Dealing Simulation 316 7.7 Case Study: Class GradeBook Using an Array to Store Grades 320 7.8 Case Study: Class GradeBook Using a Two-Dimensional Array 326 7.9 Wrap-Up 331 8 Classes and Objects: A Deeper Look 339 8.1 Introduction 340 8.2 Time Class Case Study 340 8.3 Controlling Access to Members 345 8.4 Referring to the Current Object’s Members with the this Reference 346 8.5 Time Class Case Study: Overloaded Constructors 348 8.6 Default and No-Argument Constructors 353 8.7 Notes on Set and Get Methods 354 8.8 Composition 355 8.9 enum Types 358
  • 12. 12 Contents 8.10 Garbage Collection 361 8.11 static Class Members 361 8.12 static Import 365 8.13 final Instance Variables 366 8.14 Package Access 367 8.15 Using BigDecimal for Precise Monetary Calculations 368 8.16 (Optional) GUI and Graphics Case Study: Using Objects with Graphics 371 8.17 Wrap-Up 375 9 Object-Oriented Programming: Inheritance 383 9.1 Introduction 384 9.2 Superclasses and Subclasses 385 9.3 protected Members 387 9.4 Relationship Between Superclasses and Subclasses 388 9.4.1 Creating and Using a CommissionEmployee Class 388 9.4.2 Creating and Using a BasePlusCommissionEmployee Class 393 9.4.3 Creating a CommissionEmployee–BasePlusCommissionEmployee Inheritance Hierarchy 398 9.4.4 CommissionEmployee–BasePlusCommissionEmployee Inheritance Hierarchy Using protected Instance Variables 401 9.4.5 CommissionEmployee–BasePlusCommissionEmployee Inheritance Hierarchy Using private Instance Variables 404 9.5 Constructors in Subclasses 408 9.6 Class Object 409 9.7 Designing with Composition vs. Inheritance 410 9.8 Wrap-Up 412 10 Object-Oriented Programming: Polymorphism and Interfaces 417 10.1 Introduction 418 10.2 Polymorphism Examples 420 10.3 Demonstrating Polymorphic Behavior 421 10.4 Abstract Classes and Methods 423 10.5 Case Study: Payroll System Using Polymorphism 426 10.5.1 Abstract Superclass Employee 427 10.5.2 Concrete Subclass SalariedEmployee 429 10.5.3 Concrete Subclass HourlyEmployee 431 10.5.4 Concrete Subclass CommissionEmployee 432 10.5.5 Indirect Concrete Subclass BasePlusCommissionEmployee 434 10.5.6 Polymorphic Processing, Operator instanceof and Downcasting 435 10.6 Allowed Assignments Between Superclass and Subclass Variables 440 10.7 final Methods and Classes 440 10.8 A Deeper Explanation of Issues with Calling Methods from Constructors 441 10.9 Creating and Using Interfaces 442 10.9.1 Developing a Payable Hierarchy 444
  • 13. Contents 13 10.9.2 Interface Payable 445 10.9.3 Class Invoice 445 10.9.4 Modifying Class Employee to Implement Interface Payable 447 10.9.5 Using Interface Payable to Process Invoices and Employees Polymorphically 449 10.9.6 Some Common Interfaces of the Java API 450 10.10 Java SE 8 Interface Enhancements 451 10.10.1 default Interface Methods 451 10.10.2 static Interface Methods 452 10.10.3 Functional Interfaces 452 10.11 Java SE 9 private Interface Methods 453 10.12 private Constructors 453 10.13 Program to an Interface, Not an Implementation 454 10.13.1 Implementation Inheritance Is Best for Small Numbers of Tightly Coupled Classes 454 10.13.2 Interface Inheritance Is Best for Flexibility 454 10.13.3 Rethinking the Employee Hierarchy 455 10.14 (Optional) GUI and Graphics Case Study: Drawing with Polymorphism 456 10.15 Wrap-Up 458 11 Exception Handling: A Deeper Look 465 11.1 Introduction 466 11.2 Example: Divide by Zero without Exception Handling 467 11.3 Example: Handling ArithmeticExceptions and InputMismatchExceptions 469 11.4 When to Use Exception Handling 475 11.5 Java Exception Hierarchy 475 11.6 finally Block 479 11.7 Stack Unwinding and Obtaining Information from an Exception 483 11.8 Chained Exceptions 486 11.9 Declaring New Exception Types 488 11.10 Preconditions and Postconditions 489 11.11 Assertions 489 11.12 try-with-Resources: Automatic Resource Deallocation 491 11.13 Wrap-Up 492 12 JavaFX Graphical User Interfaces: Part 1 498 12.1 Introduction 499 12.2 JavaFX Scene Builder 500 12.3 JavaFX App Window Structure 501 12.4 Welcome App—Displaying Text and an Image 502 12.4.1 Opening Scene Builder and Creating the File Welcome.fxml 502 12.4.2 Adding an Image to the Folder Containing Welcome.fxml 503 12.4.3 Creating a VBox Layout Container 503 12.4.4 Configuring the VBox Layout Container 504 12.4.5 Adding and Configuring a Label 504
  • 14. 14 Contents 12.4.6 Adding and Configuring an ImageView 505 12.4.7 Previewing the Welcome GUI 507 12.5 Tip Calculator App—Introduction to Event Handling 507 12.5.1 Test-Driving the Tip Calculator App 508 12.5.2 Technologies Overview 509 12.5.3 Building the App’s GUI 511 12.5.4 TipCalculator Class 518 12.5.5 TipCalculatorController Class 520 12.6 Features Covered in the Other JavaFX Chapters 525 12.7 Wrap-Up 525 13 JavaFX GUI: Part 2 533 13.1 Introduction 534 13.2 Laying Out Nodes in a Scene Graph 534 13.3 Painter App: RadioButtons, Mouse Events and Shapes 536 13.3.1 Technologies Overview 536 13.3.2 Creating the Painter.fxml File 538 13.3.3 Building the GUI 538 13.3.4 Painter Subclass of Application 541 13.3.5 PainterController Class 542 13.4 Color Chooser App: Property Bindings and Property Listeners 546 13.4.1 Technologies Overview 546 13.4.2 Building the GUI 547 13.4.3 ColorChooser Subclass of Application 549 13.4.4 ColorChooserController Class 550 13.5 Cover Viewer App: Data-Driven GUIs with JavaFX Collections 552 13.5.1 Technologies Overview 553 13.5.2 Adding Images to the App’s Folder 553 13.5.3 Building the GUI 553 13.5.4 CoverViewer Subclass of Application 555 13.5.5 CoverViewerController Class 555 13.6 Cover Viewer App: Customizing ListView Cells 557 13.6.1 Technologies Overview 558 13.6.2 Copying the CoverViewer App 558 13.6.3 ImageTextCell Custom Cell Factory Class 559 13.6.4 CoverViewerController Class 560 13.7 Additional JavaFX Capabilities 561 13.8 JavaFX 9: Java SE 9 JavaFX Updates 563 13.9 Wrap-Up 565 14 Strings, Characters and Regular Expressions 574 14.1 Introduction 575 14.2 Fundamentals of Characters and Strings 575 14.3 Class String 576 14.3.1 String Constructors 576
  • 15. Visit https://testbankfan.com now to explore a rich collection of testbank or solution manual and enjoy exciting offers!
  • 16. Contents 15 14.3.2 String Methods length, charAt and getChars 577 14.3.3 Comparing Strings 579 14.3.4 Locating Characters and Substrings in Strings 583 14.3.5 Extracting Substrings from Strings 585 14.3.6 Concatenating Strings 586 14.3.7 Miscellaneous String Methods 587 14.3.8 String Method valueOf 588 14.4 Class StringBuilder 589 14.4.1 StringBuilder Constructors 590 14.4.2 StringBuilder Methods length, capacity, setLength and ensureCapacity 591 14.4.3 StringBuilder Methods charAt, setCharAt, getChars and reverse 592 14.4.4 StringBuilder append Methods 593 14.4.5 StringBuilder Insertion and Deletion Methods 595 14.5 Class Character 596 14.6 Tokenizing Strings 601 14.7 Regular Expressions, Class Pattern and Class Matcher 602 14.7.1 Replacing Substrings and Splitting Strings 607 14.7.2 Classes Pattern and Matcher 609 14.8 Wrap-Up 611 15 Files, Input/Output Streams, NIO and XML Serialization 622 15.1 Introduction 623 15.2 Files and Streams 623 15.3 Using NIO Classes and Interfaces to Get File and Directory Information 625 15.4 Sequential Text Files 629 15.4.1 Creating a Sequential Text File 629 15.4.2 Reading Data from a Sequential Text File 632 15.4.3 Case Study: A Credit-Inquiry Program 633 15.4.4 Updating Sequential Files 638 15.5 XML Serialization 638 15.5.1 Creating a Sequential File Using XML Serialization 638 15.5.2 Reading and Deserializing Data from a Sequential File 644 15.6 FileChooser and DirectoryChooser Dialogs 645 15.7 (Optional) Additional java.io Classes 651 15.7.1 Interfaces and Classes for Byte-Based Input and Output 651 15.7.2 Interfaces and Classes for Character-Based Input and Output 653 15.8 Wrap-Up 654 16 Generic Collections 662 16.1 Introduction 663 16.2 Collections Overview 663
  • 17. 16 Contents 16.3 Type-Wrapper Classes 665 16.4 Autoboxing and Auto-Unboxing 665 16.5 Interface Collection and Class Collections 665 16.6 Lists 666 16.6.1 ArrayList and Iterator 667 16.6.2 LinkedList 669 16.7 Collections Methods 674 16.7.1 Method sort 674 16.7.2 Method shuffle 678 16.7.3 Methods reverse, fill, copy, max and min 680 16.7.4 Method binarySearch 682 16.7.5 Methods addAll, frequency and disjoint 683 16.8 Class PriorityQueue and Interface Queue 685 16.9 Sets 686 16.10 Maps 689 16.11 Synchronized Collections 693 16.12 Unmodifiable Collections 693 16.13 Abstract Implementations 694 16.14 Java SE 9: Convenience Factory Methods for Immutable Collections 694 16.15 Wrap-Up 698 17 Lambdas and Streams 704 17.1 Introduction 705 17.2 Streams and Reduction 707 17.2.1 Summing the Integers from 1 through 10 with a for Loop 707 17.2.2 External Iteration with for Is Error Prone 708 17.2.3 Summing with a Stream and Reduction 708 17.2.4 Internal Iteration 709 17.3 Mapping and Lambdas 710 17.3.1 Lambda Expressions 711 17.3.2 Lambda Syntax 712 17.3.3 Intermediate and Terminal Operations 713 17.4 Filtering 714 17.5 How Elements Move Through Stream Pipelines 716 17.6 Method References 717 17.6.1 Creating an IntStream of Random Values 718 17.6.2 Performing a Task on Each Stream Element with forEach and a Method Reference 718 17.6.3 Mapping Integers to String Objects with mapToObj 719 17.6.4 Concatenating Strings with collect 719 17.7 IntStream Operations 720 17.7.1 Creating an IntStream and Displaying Its Values 721 17.7.2 Terminal Operations count, min, max, sum and average 721 17.7.3 Terminal Operation reduce 722 17.7.4 Sorting IntStream Values 724
  • 18. Contents 17 17.8 Functional Interfaces 725 17.9 Lambdas: A Deeper Look 726 17.10 Stream<Integer> Manipulations 727 17.10.1 Creating a Stream<Integer> 728 17.10.2 Sorting a Stream and Collecting the Results 729 17.10.3 Filtering a Stream and Storing the Results for Later Use 729 17.10.4 Filtering and Sorting a Stream and Collecting the Results 730 17.10.5 Sorting Previously Collected Results 730 17.11 Stream<String> Manipulations 730 17.11.1 Mapping Strings to Uppercase 731 17.11.2 Filtering Strings Then Sorting Them in Case-Insensitive Ascending Order 732 17.11.3 Filtering Strings Then Sorting Them in Case-Insensitive Descending Order 732 17.12 Stream<Employee> Manipulations 733 17.12.1 Creating and Displaying a List<Employee> 734 17.12.2 Filtering Employees with Salaries in a Specified Range 735 17.12.3 Sorting Employees By Multiple Fields 738 17.12.4 Mapping Employees to Unique-Last-Name Strings 740 17.12.5 Grouping Employees By Department 741 17.12.6 Counting the Number of Employees in Each Department 742 17.12.7 Summing and Averaging Employee Salaries 743 17.13 Creating a Stream<String> from a File 744 17.14 Streams of Random Values 747 17.15 Infinite Streams 749 17.16 Lambda Event Handlers 751 17.17 Additional Notes on Java SE 8 Interfaces 751 17.18 Wrap-Up 752 18 Recursion 766 18.1 Introduction 767 18.2 Recursion Concepts 768 18.3 Example Using Recursion: Factorials 769 18.4 Reimplementing Class FactorialCalculator Using BigInteger 771 18.5 Example Using Recursion: Fibonacci Series 773 18.6 Recursion and the Method-Call Stack 776 18.7 Recursion vs. Iteration 777 18.8 Towers of Hanoi 779 18.9 Fractals 781 18.9.1 Koch Curve Fractal 782 18.9.2 (Optional) Case Study: Lo Feather Fractal 783 18.9.3 (Optional) Fractal App GUI 785 18.9.4 (Optional) FractalController Class 787 18.10 Recursive Backtracking 792 18.11 Wrap-Up 792
  • 19. 18 Contents 19 Searching, Sorting and Big O 801 19.1 Introduction 802 19.2 Linear Search 803 19.3 Big O Notation 806 19.3.1 O(1) Algorithms 806 19.3.2 O(n) Algorithms 806 19.3.3 O(n2) Algorithms 806 19.3.4 Big O of the Linear Search 807 19.4 Binary Search 807 19.4.1 Binary Search Implementation 808 19.4.2 Efficiency of the Binary Search 811 19.5 Sorting Algorithms 812 19.6 Selection Sort 812 19.6.1 Selection Sort Implementation 813 19.6.2 Efficiency of the Selection Sort 815 19.7 Insertion Sort 815 19.7.1 Insertion Sort Implementation 816 19.7.2 Efficiency of the Insertion Sort 818 19.8 Merge Sort 819 19.8.1 Merge Sort Implementation 819 19.8.2 Efficiency of the Merge Sort 824 19.9 Big O Summary for This Chapter’s Searching and Sorting Algorithms 824 19.10 Massive Parallelism and Parallel Algorithms 825 19.11 Wrap-Up 825 20 Generic Classes and Methods: A Deeper Look 831 20.1 Introduction 832 20.2 Motivation for Generic Methods 832 20.3 Generic Methods: Implementation and Compile-Time Translation 834 20.4 Additional Compile-Time Translation Issues: Methods That Use a Type Parameter as the Return Type 837 20.5 Overloading Generic Methods 840 20.6 Generic Classes 841 20.7 Wildcards in Methods That Accept Type Parameters 848 20.8 Wrap-Up 852 21 Custom Generic Data Structures 856 21.1 Introduction 857 21.2 Self-Referential Classes 858 21.3 Dynamic Memory Allocation 858 21.4 Linked Lists 859 21.4.1 Singly Linked Lists 859 21.4.2 Implementing a Generic List Class 860 21.4.3 Generic Classes ListNode and List 863
  • 20. Contents 19 21.4.4 Class ListTest 863 21.4.5 List Method insertAtFront 865 21.4.6 List Method insertAtBack 866 21.4.7 List Method removeFromFront 866 21.4.8 List Method removeFromBack 867 21.4.9 List Method print 868 21.4.10 Creating Your Own Packages 868 21.5 Stacks 873 21.6 Queues 876 21.7 Trees 878 21.8 Wrap-Up 885 22 JavaFX Graphics and Multimedia 910 22.1 Introduction 911 22.2 Controlling Fonts with Cascading Style Sheets (CSS) 912 22.2.1 CSS That Styles the GUI 912 22.2.2 FXML That Defines the GUI—Introduction to XML Markup 915 22.2.3 Referencing the CSS File from FXML 918 22.2.4 Specifying the VBox’s Style Class 918 22.2.5 Programmatically Loading CSS 918 22.3 Displaying Two-Dimensional Shapes 919 22.3.1 Defining Two-Dimensional Shapes with FXML 919 22.3.2 CSS That Styles the Two-Dimensional Shapes 922 22.4 Polylines, Polygons and Paths 924 22.4.1 GUI and CSS 925 22.4.2 PolyShapesController Class 926 22.5 Transforms 929 22.6 Playing Video with Media, MediaPlayer and MediaViewer 931 22.6.1 VideoPlayer GUI 932 22.6.2 VideoPlayerController Class 934 22.7 Transition Animations 938 22.7.1 TransitionAnimations.fxml 938 22.7.2 TransitionAnimationsController Class 940 22.8 Timeline Animations 944 22.9 Frame-by-Frame Animation with AnimationTimer 947 22.10 Drawing on a Canvas 949 22.11 Three-Dimensional Shapes 954 22.12 Wrap-Up 957 23 Concurrency 973 23.1 Introduction 974 23.2 Thread States and Life Cycle 976 23.2.1 New and Runnable States 977 23.2.2 Waiting State 977
  • 21. Random documents with unrelated content Scribd suggests to you:
  • 22. President of Washington College ROBERT EDWARD LEE From a portrait painted by Browne, now in the Westmoreland Club, Richmond, Virginia The next morning Lee, surrounded by his sorrowing men, mounted his horse, Traveler, and rode slowly away to his home in Richmond. The other Confederate armies surrendered one by one. After the war General Lee was elected president of Washington College at Lexington, Virginia, now Washington and Lee University. He greatly enjoyed his work of building up the young manhood of the
  • 23. Dies in 1870 South. He died at Lexington in 1870. A monument to the memory of this great man has been erected at Richmond, and another at Lexington. SUGGESTIONS INTENDED TO HELP THE PUPIL The Leading Facts. 1. Grant born of parents who were farmers. Loved to work with horses. 2. Sent to West Point; was in Mexican War under Generals Taylor and Scott. 3. Was clerk for his father at Galena. 4. In the Civil War rose rapidly till made a major-general. 5. Captured Fort Donelson and Fort Henry. 6. Captured Vicksburg; was made lieutenant-general, and sent into the Wilderness after General Lee. 7. Fought a month, then moved around to Petersburg. 8. Offered Lee terms of surrender. 9. Was twice made president. 10. Died at Mount McGregor. 11. Robert E. Lee was born in Virginia and went to school at Alexandria. 12. Went to West Point, and was in the Mexican War, where he earned honor and fame. 13. Took charge at West Point. 14. Followed Virginia when she seceded, and was given command of the troops defending Richmond. 15. Won several victories over the North. 16. Failed at Gettysburg. 17. Fought to save Richmond. 18. Surrendered to General Grant in spring of 1865. 19. Became president of Washington College. Study Questions. 1. Tell the story of Grant until he reached West Point. 2. What part did Grant take in the war with Mexico? 3. What did Grant do at Galena when Lincoln's call came? 4. Tell of his promotion. 5. What would happen if Vicksburg and other Mississippi River places were taken? 6. What two victories came on the Fourth of July, and what did both mean? 7. How did Grant's victory impress the president? 8. What can you tell of the "Battle of the Wilderness"? 9. What happened at Richmond? 10. Picture the scene at Appomattox Court
  • 24. House. 11. Tell the story of Grant after the Civil War. 12. Tell of Lee's promotion after leaving West Point. 13. Did Lee want his state to leave the Union? 14. Was he a victorious general at first? 15. What happened at Gettysburg? 16. Tell about Lee defending Richmond. 17. What did Lee plan to do after Richmond fell? 18. Why did he not carry out this plan? 19. What position did Lee accept after the war? Suggested Readings. Ulysses S. Grant: Burton, Four American Patriots, 195-254; Brooks, Century Book of Famous Americans, 181-191; Hart and Stevens, Romance of the Civil War, 179-183; Hale, Stories of War, 21-29, 74- 91, 92-118, 168-187, 226-264; Bolton, Famous American Statesmen, 307-360. Robert E. Lee: Hale, Stories of War, 61-73, 119, 149; Mabie, Heroes Every Child Should Know, 289-308; Magill, Stories from Virginia History, 162-172.
  • 26. MEN WHO DETERMINED NEW POLITICAL POLICIES
  • 27. RUTHERFORD B. HAYES 175. A Wise and Independent President. In 1822 a baby boy was born in the old college town of Delaware, Ohio. His parents named the boy Rutherford B. Hayes. As a youngster he loved his books and his playmates. RUTHERFORD B. HAYES
  • 28. A leader at college Becomes a general Refuses to leave his post to campaign From a photograph by Pach Bros., New York City At an early age he entered Kenyon College, Ohio. Here he was a leader among his fellows, not only in college affairs, but in his daily work in the classroom. He graduated with first honors in his class. For his after-college work Hayes decided to choose the law, and graduated from Harvard Law School. He was just beginning to win success when Lincoln's call to arms aroused the men of the North. It seemed terrible for northern men and southern men to fight against each other, but it had to be done to save the Union. Hayes volunteered and was made a major in command. By his fine work as an officer in caring for his men and in bravery on the field of battle, he won the title of general. While he was still fighting, the people at home, looking for a high-minded, honorable man for congress, nominated Hayes. His supporters sent for him to come home and canvass for votes. He would not go. He said: "An officer fit for duty who, at such a time as this, would abandon his post to electioneer for a seat in Congress, ought to be scalped." Hayes remained at his post and was elected by a large majority. Hayes had become known to all the people of his state and they wanted him for governor. So friendly was he toward all whether high or low, so honest was he that three times the people chose him to be their governor. In 1876 the Republicans of the nation selected him to be their candidate for the high office of president. The Democratic candidate was a man of very high reputation, Samuel J. Tilden of New York. He was known as a fighter for honesty and against wrongdoing in public office.
  • 29. Contest over the presidency Generous toward the South A startling change in custom Unfortunately, the politicians aroused bitter feeling between the North and the South in this campaign. When it was seen that Hayes was winner by only one vote, there were threats of "civil war." But luckily Tilden did not lose his head, and his party, following his advice, accepted the result. Hayes decided to take the Union soldiers out of the South. The radical Republicans opposed this action, but the majority of the people in the North favored it. The southern people were happy, because now they might manage their elections to suit themselves. President Hayes also placed a southern man in his cabinet, and this, too, helped along the good feeling between the North and the South. We can see now that the return of good feeling between the North and the South was necessary, but it was not so easily seen then. Now we can say that President Hayes was a noble and far-seeing statesman when he offered the "olive branch" to the South. Lucy Hayes, his wife, was a brave woman. She startled society at Washington and in the country at large by issuing a decree that no strong drink should be used in the White House. The temperance people were happy, but others were not, especially the ministers of foreign countries who had always been in the habit of using wine on social occasions. A great cry was raised throughout the country, but Lucy Webb Hayes stood her ground.
  • 30. JAMES A. GARFIELD AND CHESTER A. ARTHUR JAMES A. GARFIELD After a photograph by E. Bierstadt 176. The Towpath that Led to the Presidency. Like Lincoln, the second of our "martyr Presidents" started life in a log cabin. Garfield was born near Cleveland, Ohio (1831). His parents were poor and his father died while Garfield was yet an infant. Garfield's mother
  • 31. Determined to have an education War, Congress, and the Presidency was brave and held her little family together. The children did not have much chance to go to school. Life to them was a hard struggle. When James reached the age of fifteen, he began driving mules on the towpath of a canal running from Cleveland to Portsmouth. This was the time when canal boats carried both freight and passengers. The towpath was a hard "school," but had many good lessons for a boy wise enough to keep out of mischief. He had his heart set on an education. He went to school long enough to be able to teach school. He shared his earnings with his mother. Teaching only sharpened his appetite for an education. For a time he went to Hiram College and afterward became a teacher there. He loved Hiram College because it was supported by the Church of the Disciples, of which he was a member. He finished his education at Williams College. When Lincoln called for men for the war, Garfield, like thousands of others, volunteered. He became an officer and did his work so well that he was promoted to be major general. Like Hayes, he was elected to Congress while in the army, fighting its battles. Again and again, the people of his district sent him to Congress, and finally in 1880 the legislature of his native state made him a United States senator. Garfield was a wonderful orator. Before the Republicans, gathered in Chicago, he placed the name of John Sherman in nomination for the presidency. So great was this speech that the convention turned from all the men who were before it, and nominated Garfield himself. Garfield won the presidency before he had a chance to take his seat as United States senator. After delivering his inaugural address to the vast crowd gathered, he turned and kissed his mother. The Republicans had promised to make new rules about men appointed to office. They declared that men should not hold office
  • 32. Civil service reform just because they had worked for the party in power, but that they should pass an examination to find out whether or not they were fit for the position. While Garfield was leaving Washington to attend the Fourth of July celebration at Williams College, he was shot by a half-crazy, disappointed office seeker. He lived until September. Few young people can now understand how the American people felt during this time. They learned to hate the "spoils system." Garfield's death sealed its fate. 177. Arthur Becomes President. Chester A. Arthur was thought to be a "politician" merely, but he proved to be a good president. He began to build up a strong navy and started the movement for the reform of the civil service.
  • 33. CHESTER A. ARTHUR From a photograph by Sarony Since the days of the Civil War, we had been too busy with affairs at home to think much about the need of a navy. But beginning with President Arthur's administration we have increased its size from time to time, until during the war with Spain, our people came to feel the navy's value. Under Arthur the spoils system received its first deadly blow when Congress passed and Arthur signed a bill establishing the merit system. By this system, men are appointed to office only after they
  • 34. have proved their fitness by an examination. Under it men cannot be turned out of office except for just cause.
  • 35. Early life GROVER CLEVELAND 178. A Man Who Was Twice President. Grover Cleveland saw the light of day in the old state of New Jersey in 1837. While he was yet a boy his parents moved to central New York. Here he received a common school education. He was a good pupil and made friends with boys who loved honesty and fair play. His parents were poor and could not send him to college. He was always sorry for this and tried to make up for it by hard study. The lives of men great in history and literature were what he liked best to read.
  • 36. Lawyer, mayor, and governor GROVER CLEVELAND From a photograph by Bell After going to Buffalo, young Cleveland entered upon the study of law. He studied long upon the fine points of the law. In time he became one of the ablest lawyers, not only in Buffalo, but in the State of New York. The fact that young Cleveland was chosen sheriff of Erie County shows that a great many people already looked upon him as a courageous man. When Buffalo needed a mayor who was not afraid to do his duty, the people elected this man who had been a good sheriff.
  • 37. Runs against Blaine The panic of 1893 The great railroad strike The people of the State of New York wanted a man of the Cleveland type for governor. He carried the state by a great majority. He was a great governor as he had been a great mayor. He was honest and straightforward, and treated all men alike. Long before his time as governor was up, the people began to talk of him for president. Cleveland ran against a widely known and popular man, James G. Blaine of Maine. But the Republicans split and Cleveland won. The Democrats were happy over the result, for this was the first time they had elected a president since 1856. The Republicans had kept a high tariff ever since the Civil War. The result was that our treasury at Washington was full of money. Cleveland sent a message to Congress asking that the tariff be cut down, but the high-tariff Democrats joined the Republicans in supporting it. Cleveland had made many enemies in his own party by refusing to appoint unfit men to office. When, therefore, he ran for president again in 1888, he was beaten by Senator Harrison of Indiana. But four years later, in 1892, he defeated Harrison and again became president. 179. The Panic of 1893. Cleveland had hardly taken his seat as President when hard times struck the country. Business men and laborers suffered greatly. They could not pay their debts. Men, women, and children suffered for want of bread. The Pullman Car Company of Chicago cut down the wages of its workmen. The men called a strike which finally extended over half the states of the Union. Chicago was the center of the strike. Hundreds of cars were burned and lives were threatened. It was impossible to carry the United States mail or freight from one state to another. Grover Cleveland ordered United States soldiers to Chicago to keep the mails going
  • 38. and the freight running. This broke the back of the strike. Cleveland had shown how to settle strikes in a new way. Cleveland served twice as President and after his second term of office he moved to Princeton, New Jersey, the seat of Princeton University. Here he became famous for his lectures given before the student body.
  • 39. BENJAMIN HARRISON BENJAMIN HARRISON From a photograph by L. Alman 180. A General Who Became President. Early in our national history it had happened that the son of a President of the United States had also become President. In 1833 a boy was born in Ohio, the grandson of a President, who was also to gain this high position.
  • 40. Enters the army Active in politics A picturesque campaign His grandfather was William Henry Harrison, who was elected President in the stirring campaign of 1840. His parents named him Benjamin. Young Harrison, a happy and well-born boy, received his education in the public schools. He entered Miami University at an early age and graduated at eighteen. Harrison, like so many of our other presidents, studied law. He was very soon admitted to the bar, and in 1854 he went to live in the Hoosier State at Indianapolis. He answered the call to arms. He was made a lieutenant, but had hardly learned his duties before he was promoted to be captain of a company of one hundred men. Hardly a month passed before an order came making him a colonel of a regiment of a thousand men. He led this regiment until the last days of the war, and the boys were proud of "Colonel Ben." For personal bravery and for skill in handling his men in one of the battles in Georgia, he was made major general. After the war Harrison returned to the law. In political campaigns he was much sought after to speak in all parts of the state. He did not accept office until he was elected United States senator in 1881. Senator Harrison was nominated for the presidency in 1888. He set the example of making speeches "on his front porch" to admiring crowds who came from different states. In this campaign the Democrats pointed to Harrison as a man who wore his "grandfather's hat." The Republicans made this campaign like that of 1840. There was great enthusiasm, big wagons carrying log cabins with raccoons and barrels of hard cider, great balls rolling on, and happy songs. Tippecanoe clubs were formed in all parts of the country. The result was the election of Harrison.
  • 41. Pensions and the tariff Under President Harrison a tariff law was passed with a reciprocity agreement. By this arrangement, the United States agreed to reduce its tariff if other nations would reduce theirs. President Harrison had a warm spot in his heart for the old soldiers, and he signed with pleasure a new pension law. The farmers and the silver men of the West were becoming dissatisfied with the action of Congress. In 1890 their forces elected several new Congressmen, and in the next year formed the People's party. Most of the votes of this party were drawn from the Republican side, hence in the next campaign Harrison was defeated by Cleveland. SUGGESTIONS INTENDED TO HELP THE PUPIL The Leading Facts. 1. Hayes studied law, and served in the Civil War. 2. He was elected to Congress while still in the field. 3. He received only one more vote than Tilden for President. 4. He was wise and fair in his treatment of the South. 5. Garfield was a poor boy who had to work hard for an education. 6. He was a war veteran and was elected senator before becoming President. 7. His remarkable ability as an orator caused him to be nominated for the presidency. 8. His assassination helped to bring civil service reform. 9. Arthur when President, worked for a larger navy. 10. He supported civil service against the spoils system. 11. Cleveland, after being mayor of Buffalo and governor of New York, was elected President twice, though not in succession. 12. A severe panic occurred while he was President. 13. Harrison studied law, and became a general during the Civil War. 14. His election was like that of his grandfather, William Henry Harrison. 15. Changes in the tariff and in pension laws took place during his presidency. 16. At the following election the farmers and those favoring silver money
  • 42. combined in the Populist party, reducing the Republican vote and causing the election of Cleveland. Study Questions. 1. Tell something of Hayes' early life. 2. How did he come to be chosen Congressman? 3. What was unusual about his election to the presidency? 4. How was his election accepted by the country? 5. What kind of a President did he make? 6. What can you tell of Garfield's youth? 7. What positions did he hold before becoming President? 8. What brought about his nomination? 9. What reform did the nation demand after Garfield's assassination? 10. What two things did Arthur work for? 11. What positions did Cleveland hold? 12. Name two important things that happened while he was President. 13. Tell something of Harrison's career and election. 14. What was done about the tariff and pensions during his presidency? 15. Why was Harrison defeated by Cleveland in the next election? Suggested Readings. Higginson, History of the United States, 330-347; Guerber, Story of the Great Republic, 281-285, 288-293.
  • 44. THE BEGINNING OF EXPANSION ABROAD
  • 45. WILLIAM McKINLEY AND THE SPANISH- AMERICAN WAR WILLIAM McKINLEY From a photograph by Courtney, taken at Canton, Ohio
  • 46. William McKinley, 1843 Teaches school Enlists to fight for the Union Wins praise and promotion Studies law Becomes a successful lawyer and speaker In Congress Elected president 181. William McKinley. William McKinley was born in Ohio in 1843. As a boy his chief delight was to roam the fields and woods surrounding Niles, his home town, or to fish in the fine streams near by. When he was about nine years old his parents moved to Poland, Ohio, where there were good schools for children. McKinley studied hard, and at seventeen years of age entered Allegheny College at Meadville, Pennsylvania. But his health had never been very good and he fell ill from hard study. He returned to Poland, and there a little later he taught school. In 1861 Lincoln's call for troops to save the Union fired the whole North with patriotism. McKinley, though then only eighteen years of age, enlisted at once. Under fire at Antietam and in later battles of the war, he won praise and promotion for his heroic deeds. The active army life was good for him, and when the war was over he was a strong and healthy man. He enlisted as a private and came out as a major. All his promotions were for merit and bravery. He returned to Poland and took up the study of the law. But his means were small and he had a hard struggle. In 1867 McKinley was admitted to the bar and opened an office in Canton, Ohio. Like many another young lawyer he had numerous difficulties and disappointments, but he worked hard and in time became a successful lawyer. He was a good speaker and soon was much in demand in political campaigns. The people admired him. They felt that he could be trusted. They sent him, for seven terms, to represent them in Congress at Washington, and twice they made him governor of Ohio. In 1896 he was elected president of the United States.
  • 47. The Cubans revolt Americans 182. Spanish Persecution in Cuba. Since the earliest days of Spanish rule, Cuba had been discontented and had engaged in frequent wars with Spain because of heavy taxation and bad government. Again and again the Cubans revolted, but they were not strong enough to succeed and Spanish oppression continued. In 1895 the people rose in a last desperate effort to free themselves. To crush them Spain sent a large army under a cruel general. Large numbers of unarmed Cubans—men, women, and children—were gathered into camps guarded by Spanish soldiers and cut off from food and other supplies. Thousands died of starvation and disease. HOW THE CUBANS FOUGHT Lying in ambush for the advancing column of the enemy These and other harsh things done in an attempt to break the spirit of the Cubans filled the
  • 48. aroused Red Cross Society goes to Cuba American people with bitter indignation. On the recommendation of President McKinley, Congress voted fifty thousand dollars for relief work. Money, by private contribution, also flowed in from all parts of the country. The Red Cross Society, led by Clara Barton, hastened to the island to relieve the awful conditions of hunger and disease. GEORGE DEWEY From a photograph taken in 1900 by Francis B. Johnston, Washington, D.C.
  • 49. Battleship "Maine" blown up War declared Dewey destroys the Spanish fleet California volunteers lead in numbers The American people were aroused. They demanded that the United States interfere in behalf of the suffering Cubans, who were fighting to be free. They were eager to take up arms for freedom and humanity. Indignation was brought to its highest pitch when, on February 15, 1898, the United States battleship Maine was sunk in Havana Harbor, two hundred sixty of the crew perishing. What was the cause of the explosion has never been found out, but Americans then believed it to be the work of the Spaniards. In April the United States demanded that the Spanish troops be taken from Cuba and the Cubans be given their independence. Spain was given three days in which to reply. She immediately declared war against the United States. 183. A War for the Sake of Humanity. The war had hardly begun before Admiral George Dewey destroyed the Spanish fleet and pounded to pieces the shore batteries in Manila Bay, Philippine Islands. Dewey, with his fleet, sailed under orders from Hong-kong, China, entered the bay, and did his work without the loss of a man. This deed made him the naval hero of the war. Thousands of men, North and South, rallied to the call of President McKinley. The states of the far West responded with noble enthusiasm. California, largest in population and wealth, led in the number of its volunteers.
  • 50. "Rough Riders" win fame SCENE OF THE SPANISH WAR IN THE PHILIPPINES The land forces in Cuba were under the command of General Shafter. They stormed El Caney and San Juan and marched on Santiago. But the "Rough Riders," a regiment raised from the mountains and plains, attracted the most attention. Colonel Leonard Wood had command of them, aided by Theodore Roosevelt. When Wood was made a general, Roosevelt became their colonel, and fought through the war with them. A large fleet sent from Spain under Admiral Cervera had kept out of the way of the American fleet under Rear-Admiral Sampson and
  • 51. Spanish fleet in Santiago Harbor Cervera's fleet destroyed Treaty of peace signed The Philippines bought for twenty million dollars Commodore Schley and was now hidden in Santiago Harbor. When the Americans captured El Caney and San Juan, the Spanish admiral decided that Santiago would soon be in American hands. To escape being taken prisoner he made a bold dash from the harbor. THE BATTLE OF MANILA BAY The American naval forces were on the watch, and soon the entire Spanish fleet was destroyed or captured—July 3, 1898. The occupation by the Americans of the city of Manila, in the Philippines, in August (1898), brought peace proposals from Spain. These were accepted, the treaty being signed on the tenth of December. This war was fought for the sake of humanity and freedom and not for gain or glory. The United States had taken the side of an oppressed people struggling for independence but she did not claim these countries as the spoils of war. She paid Spain twenty million dollars in gold for the Philippines, and at once set to work to establish schools, build good roads, help the farmers, and improve living conditions by making the government more stable and humane.
  • 52. Hawaiian Islands annexed Cuba a republic Conditions in Cuba greatly improved United States a world power It had long been felt, especially by the people of the Pacific States, that for both commercial and military reasons the Hawaiian Islands should belong to us. These islands—eight in all—were annexed in 1898. Steps were taken at once to give the people of Cuba a government of their own. The island was made a republic. The constitution, drawn up somewhat like our own, was adopted by the people of Cuba, February 21, 1902. The United States did much to help the people before it withdrew from the island in 1902 and left the Cubans to rule themselves. Conditions have rapidly improved. In 1894, under Spanish rule, there were only about 900 public schools, and, even including the 700 private schools, only about 60,000 pupils were on the rolls. Six years later, under American rule, there were 3,550 public schools, with 172,000 pupils enrolled. By the conduct of their government the Cubans are justifying the confidence the American people had in them. THE BATTLE OF SANTIAGO As a result of the war Guam and Porto Rico also became American possessions. This was the beginning of American territorial
  • 53. McKinley shot by an anarchist in 1901 expansion. The United States took its place among the great world powers, and has since played an important part in the affairs of nations. 184. McKinley Assassinated. President McKinley did not live to see the results of self-government in Cuba. Shortly after his election to a second term as president, he was shot by an anarchist, while the guest of the Pan-American Exposition at Buffalo in September, 1901. After a week of patient suffering, watched with painful anxiety by the people, William McKinley, our third martyr president, passed away. SUGGESTIONS INTENDED TO HELP THE PUPIL The Leading Facts. 1. William McKinley was born in Ohio. 2. He went to college at Meadville, Pennsylvania, and afterwards taught school. 3. Enlisted as a private in 1861 and won praise and promotion for bravery in fighting for the Union. 4. After the war he studied law and opened an office in Canton, Ohio. 5. Was a good speaker and was sent to Congress at Washington for seven terms. 6. Twice governor of Ohio, he was elected president of the United States in 1896. 7. The Cubans had revolted many times against Spanish oppression and now rose again. 8. The Americans sympathized with the suffering Cubans; Congress voted fifty thousand dollars for relief work. 9. The United States battleship Maine blown up in Havana Harbor. 10. Spain declared war against the United States. 11. Admiral George Dewey destroyed the Spanish fleet at Manila in the Philippine Islands. 12. American forces, among them the Rough Riders, attacked the Spanish in Cuba. 13. American fleet destroyed the Spanish fleet at Santiago. 14. Peace proposals came from Spain and the treaty of peace was signed in December, 1898. 15. The United States bought the Philippines from Spain, the
  • 54. Hawaiian Islands were annexed, and Cuba became a republic. 16. Guam and Porto Rico also became American possessions. 17. Conditions in former Spanish possessions greatly improved. 18. McKinley was assassinated by an anarchist while he was the guest of the Pan-American Exposition at Buffalo, in September, 1901 and died soon after. Study Questions. 1. Describe McKinley's boyhood surroundings and what he liked to do. 2. What made him fall ill? 3. How did he answer Lincoln's call for troops? 4. What effect did army life have on his health? 5. What did he do after the war? 6. To what public office was he elected? 7. Why did the Cubans revolt against Spain? 8. How did the Spaniards attempt to crush the revolt? 9. What did the Americans do to relieve the suffering of the Cubans? 10. What did they want to do? 11. How did the sinking of the Maine affect Americans? 12. What did the United States demand of Spain? 13. Describe Dewey's action at Manila. 14. What state led in the number of volunteers? 15. What were the "Rough Riders"? 16. What happened at Santiago? 17. What finally brought peace proposals from Spain? 18. Why had the war been fought? 19. What did the Americans do in the Philippines? 20. What other islands came into American possession? 21. What happened in Cuba? 22. When and in what city was President McKinley assassinated? Suggested Readings. Stratemeyer, American Boy's Life of William McKinley; Morris, The War with Spain, 150-169, 180-214, 267-285; Barrett, Admiral George Dewey, 55- 152, 230-251; Ross, Heroes of Our War with Spain.
  • 56. THE MAN WHO WAS THE CHAMPION OF DEMOCRACY
  • 57. 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! ebookluna.com