Starting Out With Java From Control Structures
Through Objects 7e Tony Gaddis download
https://ebookbell.com/product/starting-out-with-java-from-
control-structures-through-objects-7e-tony-gaddis-46116578
Explore and download more ebooks at ebookbell.com
Here are some recommended products that we believe you will be
interested in. You can click the link to download.
Starting Out With Java From Control Structures Through Objects 7th
Edition Tony Gaddis
https://ebookbell.com/product/starting-out-with-java-from-control-
structures-through-objects-7th-edition-tony-gaddis-49695132
Starting Out With Java From Control Structures Through Objects Plus
Myprogramminglab With Pearson Etext Access Card Package 6th Gaddis
https://ebookbell.com/product/starting-out-with-java-from-control-
structures-through-objects-plus-myprogramminglab-with-pearson-etext-
access-card-package-6th-gaddis-22020002
Starting Out With Java From Control Structures Through Objects 5th
Edition Tony Gaddis
https://ebookbell.com/product/starting-out-with-java-from-control-
structures-through-objects-5th-edition-tony-gaddis-4078718
Starting Out With Java From Control Structures Through Objects
Testbank 5th Edition Tony Gaddis
https://ebookbell.com/product/starting-out-with-java-from-control-
structures-through-objects-testbank-5th-edition-tony-gaddis-5106146
Starting Out With Java From Control Structures Through Objects
Powerpoint Lecture Slides 5th Edition Tony Gaddis
https://ebookbell.com/product/starting-out-with-java-from-control-
structures-through-objects-powerpoint-lecture-slides-5th-edition-tony-
gaddis-5106112
Starting Out With Java From Control Structures Through Data Structures
Whats New In Computer Science 4th Edition Gaddis
https://ebookbell.com/product/starting-out-with-java-from-control-
structures-through-data-structures-whats-new-in-computer-science-4th-
edition-gaddis-11164558
Starting Out With Java From Control Structures Through Data Structures
2nd Edition Tony Gaddis
https://ebookbell.com/product/starting-out-with-java-from-control-
structures-through-data-structures-2nd-edition-tony-gaddis-4671166
Starting Out With Java Early Objects Fifth Edition Gaddis Tony
https://ebookbell.com/product/starting-out-with-java-early-objects-
fifth-edition-gaddis-tony-21355090
Starting Out With Java 5 Lab Manual Diane Christen
https://ebookbell.com/product/starting-out-with-java-5-lab-manual-
diane-christen-5399056
Starting Out With Java ™
From Control Structures through Objects
Starting Out With Java ™
From Control Structures through Objects
SEVENTH EDITION
Tony Gaddis
Haywood Community College
330 Hudson Street, NY NY 10013
Senior Vice President Courseware Portfolio Management: Marcia J.
Horton
Director, Portfolio Management: Engineering, Computer Science &
Global Editions: Julian Partridge
Portfolio Manager: Matt Goldstein
Portfolio Management Assistant: Meghan Jacoby
Managing Content Producer: Scott Disanno
Content Producer: Amanda Brands
Rights and Permissions Manager: Ben Ferrini
Manufacturing Buyer, Higher Ed, Lake Side Communications, Inc.
(LSC): Maura Zaldivar-Garcia
Inventory Manager: Ann Lam
Product Marketing Manager: Yvonne Vannatta
Field Marketing Manager: Demetrius Hall
Marketing Assistant: Jon Bryant
Cover Designer: Joyce Wells
Cover Photo: Shutterstock/Tim UR
Printer/Binder: LSC Communications, Inc.
Full-Service Project Management: Sasibalan Chidambaram, SPi Global
Credits and acknowledgments borrowed from other sources and
reproduced, with permission, in this textbook appear on appropriate page
within text.
Copyright © 2019, 2016, 2013 by Pearson Education, Inc., Hoboken, New
Jersey 07030. All rights reserved. Manufactured in the United States of
America. This publication is protected by copyright and permissions
should be obtained from the publisher prior to any prohibited
reproduction, storage in a retrieval system, or transmission in any form or
by any means, electronic, mechanical, photocopying, recording, or
likewise. For information regarding permissions, request forms and the
appropriate contacts within the Pearson Education Global Rights &
Permissions department, please visit http://www.pearsoned.com/
permissions/.
Many of the designations by manufacturers and seller to distinguish their
products are claimed as trademarks. Where those designations appear in
this book, and the publisher was aware of a trademark claim, the
designations have been printed in initial caps or all caps.
Unless otherwise indicated herein, any third-party trademarks that may
appear in this work are the property of their ­
respective owners and any
references to third-party trademarks, logos or other trade dress are for
demonstrative or descriptive purposes only. Such references are not
intended to imply any sponsorship, endorsement, authorization, or
promotion of Pearson’s products by the owners of such marks, or any
relationship between the owner and Pearson Education, Inc. or its
affiliates, authors, licensees or distributors.
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 suppliers 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 typographical errors changes are periodically
added to the information herein. Microsoft and/or its respective suppliers
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 Windows , and Microsoft Office are registered trademarks of
the Microsoft Corporation in the U.S.A. and other countries. This book is
not sponsored or endorsed by or affiliated with the Microsoft
Corporation.
Oracle and Java are registered trademarks of Oracle and/or its affiliates.
Other names may be trademarks of their respective owners.
Library of Congress Cataloging-in-Publication Data
Names: Gaddis, Tony, author.
Title: Starting out with Java. From control structures through objects /
Tony Gaddis, Haywood Community College.
Description: Seventh edition. | NY, NY : Pearson Education, Inc., [2019] |
Includes index.
Identifiers: LCCN 2017060354| ISBN 9780134802213 | ISBN 0134802217
Subjects: LCSH: Java (Computer program language) | Data structures
(Computer science) | Object-oriented programming (Computer science)
® ® ®
Classification: LCC QA76.73.J38 G333 2019 | DDC 005.13/3--dc23 LC
record
available at https://lccn.loc.gov/2017060354
1 18
ISBN 10: 0-13-480221-7
ISBN 13: 978-0-13-480221-3
Contents in Brief
Chapter 1 Introduction to Computers and Java 1
Chapter 2 Java Fundamentals 27
Chapter 3 Decision Structures 111
Chapter 4 Loops and Files 189
Chapter 5 Methods 269
Chapter 6 A First Look at Classes 317
Chapter 7 Arrays and the ArrayList Class 403
Chapter 8 A Second Look at Classes and Objects 493
Chapter 9 Text Processing and More about Wrapper Classes 557
Chapter 10 Inheritance 611
Chapter 11 Exceptions and Advanced File I/O 701
Chapter 12 JavaFX: GUI Programming and Basic Controls 759
Chapter 13 JavaFX: Advanced Controls 823
Chapter 14 JavaFX: Graphics, Effects, and Media 909
Chapter 15 Recursion 999
Chapter 16 Databases 1027
Index 1109
Appendices A–M Companion Website
Case Studies 1–7 Companion Website

















Chapters 17–20 Companion Website
Contents
Preface xxiii
Chapter 1 Introduction to Computers and Java 1
1.1 Introduction 1
1.2 Why Program? 1
1.3 Computer Systems: Hardware and Software 2
Hardware 2
Software 5
1.4 Programming Languages 6
What Is a Program? 6
A History of Java 8
1.5 What Is a Program Made Of? 8
Language Elements 8
Lines and Statements 11
Variables 11
The Compiler and the Java Virtual Machine 12
Java Software Editions 13
Compiling and Running a Java Program 14
1.6 The Programming Process 16
Software Engineering 18
1.7 Object-Oriented Programming 19
Review Questions and Exercises 21





















Programming Challenge 25
Chapter 2 Java Fundamentals 27
2.1 The Parts of a Java Program 27
2.2 The print and println Methods, and the Java API 33
2.3 Variables and Literals 39
Displaying Multiple Items with the Operator 40
Be Careful with Quotation Marks 41
More about Literals 42
Identifiers 42
Class Names 44
2.4 Primitive Data Types 44
The Integer Data Types 46
Floating-Point Data Types 47
The boolean Data Type 50
The char Data Type 50
Variable Assignment and Initialization 52
Variables Hold Only One Value at a Time 53
2.5 Arithmetic Operators 54
Integer Division 57
Operator Precedence 57
Grouping with Parentheses 59
The Math Class 62
2.6 Combined Assignment Operators 63





+ 

















2.7 Conversion between Primitive Data Types 65
Mixed Integer Operations 67
Other Mixed Mathematical Expressions 68
2.8 Creating Named Constants with final 69
2.9 The String Class 70
Objects Are Created from Classes 71
The String Class 71
Primitive Type Variables and Class Type Variables 71
Creating a String Object 72
2.10 Scope 76
2.11 Comments 78
2.12 Programming Style 83
2.13 Reading Keyboard Input 85
Reading a Character 89
Mixing Calls to nextLine with Calls to Other Scanner Methods 89
2.14 Dialog Boxes 93
Displaying Message Dialogs 93
Displaying Input Dialogs 94
An Example Program 94
Converting String Input to Numbers 96
2.15 Common Errors to Avoid 99
Review Questions and Exercises 100
Programming Challenges 106























Chapter 3 Decision Structures 111
3.1 The if Statement 111
Using Relational Operators to Form Conditions 113
Putting It All Together 114
Programming Style and the if Statement 117
Be Careful with Semicolons 117
Having Multiple Conditionally Executed Statements 118
Flags 118
Comparing Characters 119
3.2 The if-else Statement 120
3.3 Nested if Statements 122
3.4 The if-else-if Statement 128
3.5 Logical Operators 134
The Precedence of Logical Operators 139
Checking Numeric Ranges with Logical Operators 140
3.6 Comparing String Objects 142
Ignoring Case in String Comparisons 146
3.7 More about Variable Declaration and Scope 147
3.8 The Conditional Operator (Optional) 149
3.9 The switch Statement 150
3.10 Displaying Formatted Output with System.out.printf and
String.format 160
Format Specifier Syntax 163






















Precision 164
Specifying a Minimum Field Width 164
Flags 167
Formatting String Arguments 170
The String.format Method 172
3.11 Common Errors to Avoid 174
Review Questions and Exercises 175
Programming Challenges 181
Chapter 4 Loops and Files 189
4.1 The Increment and Decrement Operators 189
The Difference between Postfix and Prefix Modes 192
4.2 The while Loop 193
The while Loop Is a Pretest Loop 196
Infinite Loops 196
Don’t Forget the Braces with a Block of Statements 197
Programming Style and the while Loop 198
4.3 Using the while Loop for Input Validation 200
4.4 The do-while Loop 204
4.5 The for Loop 207
The for Loop Is a Pretest Loop 210
Avoid Modifying the Control Variable in the Body of the for Loop 211
Other Forms of the Update Expression 211
Declaring a Variable in the for Loop’s Initialization Expression 211























Creating a User Controlled for Loop 212
Using Multiple Statements in the Initialization and Update Expressions 213
4.6 Running Totals and Sentinel Values 216
Using a Sentinel Value 219
4.7 Nested Loops 221
4.8 The break and continue Statements (Optional) 229
4.9 Deciding Which Loop to Use 229
4.10 Introduction to File Input and Output 230
Using the PrintWriter Class to Write Data to a File 230
Appending Data to a File 236
Specifying the File Location 237
Reading Data from a File 237
Reading Lines from a File with the nextLine Method 238
Adding a throws Clause to the Method Header 241
Checking for a File’s Existence 245
4.11 Generating Random Numbers with the Random Class 249
4.12 Common Errors to Avoid 255
Review Questions and Exercises 256
Programming Challenges 262
Chapter 5 Methods 269
5.1 Introduction to Methods 269
void Methods and Value-Returning Methods 270
Defining a void Method 271























Calling a Method 272
Layered Method Calls 276
Using Documentation Comments with Methods 277
5.2 Passing Arguments to a Method 279
Argument and Parameter Data Type Compatibility 281
Parameter Variable Scope 282
Passing Multiple Arguments 282
Arguments Are Passed by Value 284
Passing Object References to a Method 285
Using the @param Tag in Documentation Comments 288
5.3 More about Local Variables 290
Local Variable Lifetime 292
Initializing Local Variables with Parameter Values 292
5.4 Returning a Value from a Method 293
Defining a Value-Returning Method 293
Calling a Value-Returning Method 294
Using the @return Tag in Documentation Comments 296
Returning a boolean Value 300
Returning a Reference to an Object 300
5.5 Problem Solving with Methods 302
Calling Methods That Throw Exceptions 305
5.6 Common Errors to Avoid 305
Review Questions and Exercises 306























Programming Challenges 311
Chapter 6 A First Look at Classes 317
6.1 Objects and Classes 317
Classes: Where Objects Come From 318
Classes in the Java API 319
Primitive Variables vs. Objects 321
6.2 Writing a Simple Class, Step by Step 324
Accessor and Mutator Methods 338
The Importance of Data Hiding 338
Avoiding Stale Data 339
Showing Access Specification in UML Diagrams 339
Data Type and Parameter Notation in UML Diagrams 339
Layout of Class Members 340
6.3 Instance Fields and Methods 341
6.4 Constructors 346
Showing Constructors in a UML Diagram 348
Uninitialized Local Reference Variables 348
The Default Constructor 348
Writing Your Own No-Arg Constructor 349
The String Class Constructor 350
6.5 Passing Objects as Arguments 358
6.6 Overloading Methods and Constructors 370
The BankAccount Class 372























Overloaded Methods Make Classes More Useful 378
6.7 Scope of Instance Fields 378
Shadowing 379
6.8 Packages and import Statements 380
Explicit and Wildcard import Statements 380
The java.lang Package 381
Other API Packages 381
6.9 Focus on Object-Oriented Design: Finding the Classes and Their
Responsibilities 382
Finding the Classes 382
Identifying a Class’s Responsibilities 385
This Is Only the Beginning 388
6.10 Common Errors to Avoid 388
Review Questions and Exercises 389
Programming Challenges 394
Chapter 7 Arrays and the ArrayList Class 403
7.1 Introduction to Arrays 403
Accessing Array Elements 405
Inputting and Outputting Array Contents 406
Java Performs Bounds Checking 409
Watch Out for Off-by-One Errors 410
Array Initialization 411
Alternate Array Declaration Notation 412






















7.2 Processing Array Elements 413
Array Length 415
The Enhanced for Loop 416
Letting the User Specify an Array’s Size 417
Reassigning Array Reference Variables 419
Copying Arrays 420
7.3 Passing Arrays as Arguments to Methods 422
7.4 Some Useful Array Algorithms and Operations 426
Comparing Arrays 426
Summing the Values in a Numeric Array 427
Getting the Average of the Values in a Numeric Array 428
Finding the Highest and Lowest Values in a Numeric Array 428
The SalesData Class 429
Partially Filled Arrays 437
Working with Arrays and Files 438
7.5 Returning Arrays from Methods 439
7.6 String Arrays 441
Calling String Methods from an Array Element 443
7.7 Arrays of Objects 444
7.8 The Sequential Search Algorithm 447
7.9 Two-Dimensional Arrays 450
Initializing a Two-Dimensional Array 454
The length Field in a Two-Dimensional Array 455























Displaying All the Elements of a Two-Dimensional Array 457
Summing All the Elements of a Two-Dimensional Array 457
Summing the Rows of a Two-Dimensional Array 458
Summing the Columns of a Two-Dimensional Array 458
Passing Two-Dimensional Arrays to Methods 459
Ragged Arrays 461
7.10 Arrays with Three or More Dimensions 462
7.11 The Selection Sort and the Binary Search Algorithms 463
The Selection Sort Algorithm 463
The Binary Search Algorithm 466
7.12 Command-Line Arguments and Variable-Length Argument Lists 468
Command-Line Arguments 469
Variable-Length Argument Lists 470
7.13 The ArrayList Class 472
Creating and Using an ArrayList Object 473
Using the Enhanced for Loop with an ArrayList 474
The ArrayList Class’s toString method 475
Removing an Item from an ArrayList 476
Inserting an Item 477
Replacing an Item 478
Capacity 479
Storing Your Own Objects in an ArrayList 479






















Using the Diamond Operator for Type Inference 480
7.14 Common Errors to Avoid 481
Review Questions and Exercises 481
Programming Challenges 486
Chapter 8 A Second Look at Classes and Objects 493
8.1 Static Class Members 493
A Quick Review of Instance Fields and Instance Methods 493
Static Members 494
Static Fields 494
Static Methods 497
8.2 Passing Objects as Arguments to Methods 500
8.3 Returning Objects from Methods 503
8.4 The toString Method 505
8.5 Writing an equals Method 509
8.6 Methods That Copy Objects 512
Copy Constructors 514
8.7 Aggregation 515
Aggregation in UML Diagrams 523
Security Issues with Aggregate Classes 523
Avoid Using null References 525
8.8 The this Reference Variable 528
Using this to Overcome Shadowing 529






















Using this to Call an Overloaded Constructor from Another Constructor
530
8.9 Enumerated Types 531
Enumerated Types Are Specialized Classes 532
Switching On an Enumerated Type 538
8.10 Garbage Collection 540
The finalize Method 542
8.11 Focus on Object-Oriented Design: Class Collaboration 542
Determining Class Collaborations with CRC Cards 545
8.12 Common Errors to Avoid 546
Review Questions and Exercises 547
Programming Challenges 551
Chapter 9 Text Processing and More about Wrapper Classes 557
9.1 Introduction to Wrapper Classes 557
9.2 Character Testing and Conversion with the Character Class 558
Character Case Conversion 563
9.3 More String Methods 566
Searching for Substrings 566
Extracting Substrings 572
Methods That Return a Modified String 576
The Static valueOf Methods 577
9.4 The StringBuilder Class 579
The StringBuilder Constructors 580
Other StringBuilder Methods 581























The toString Method 584
9.5 Tokenizing Strings 589
9.6 Wrapper Classes for the Numeric Data Types 594
The Static toString Methods 594
The toBinaryString , toHexString , and toOctalString Methods
594
The MIN_VALUE and MAX_VALUE Constants 595
Autoboxing and Unboxing 595
9.7 Focus on Problem Solving: The TestScoreReader Class 597
9.8 Common Errors to Avoid 601
Review Questions and Exercises 601
Programming Challenges 605
Chapter 10 Inheritance 611
10.1 What Is Inheritance? 611
Generalization and Specialization 611
Inheritance and the “Is a” Relationship 612
Inheritance in UML Diagrams 620
The Superclass’s Constructor 621
Inheritance Does Not Work in Reverse 623
10.2 Calling the Superclass Constructor 624
When the Superclass Has No Default or No-Arg Constructors 630
Summary of Constructor Issues in Inheritance 631
10.3 Overriding Superclass Methods 632






















Overloading versus Overriding 637
Preventing a Method from Being Overridden 640
10.4 Protected Members 641
Package Access 646
10.5 Chains of Inheritance 647
Class Hierarchies 653
10.6 The Object Class 653
10.7 Polymorphism 655
Polymorphism and Dynamic Binding 656
The “Is-a” Relationship Does Not Work in Reverse 658
The instanceof Operator 659
10.8 Abstract Classes and Abstract Methods 660
Abstract Classes in UML 666
10.9 Interfaces 667
An Interface is a Contract 669
Fields in Interfaces 673
Implementing Multiple Interfaces 673
Interfaces in UML 673
Default Methods 674
Polymorphism and Interfaces 676
10.10 Anonymous Inner Classes 681
10.11 Functional Interfaces and Lambda Expressions 684
10.12 Common Errors to Avoid 689























Review Questions and Exercises 690
Programming Challenges 696
Chapter 11 Exceptions and Advanced File I/O 701
11.1 Handling Exceptions 701
Exception Classes 702
Handling an Exception 703
Retrieving the Default Error Message 707
Polymorphic References to Exceptions 710
Using Multiple catch Clauses to Handle Multiple Exceptions 710
The finally Clause 718
The Stack Trace 720
Handling Multiple Exceptions with One catch Clause 721
When an Exception Is Not Caught 723
Checked and Unchecked Exceptions 724
11.2 Throwing Exceptions 725
Creating Your Own Exception Classes 728
Using the @exception Tag in Documentation Comments 731
11.3 Advanced Topics: Binary Files, Random Access Files, and Object Serialization
732
Binary Files 732
Random Access Files 739
Object Serialization 744
Serializing Aggregate Objects 748






















11.4 Common Errors to Avoid 749
Review Questions and Exercises 749
Programming Challenges 755
Chapter 12 JavaFX: GUI Programming and Basic Controls 759
12.1 Graphical User Interfaces 759
Event-Driven GUI Programs 761
12.2 Introduction to JavaFX 762
Controls 762
Stages and Scenes 763
The Application Class 763
12.3 Creating Scenes 765
Creating Controls 766
Creating Layout Containers 766
Creating a Scene Object 767
Adding the Scene Object to the Stage 768
Setting the Size of the Scene 770
Aligning Controls in an HBox Layout Container 770
12.4 Displaying Images 772
Loading Images from an Internet Location 775
Setting the Size of an Image 775
Preserving the Image’s Aspect Ratio 775
Changing an ImageView’s Image 776
12.5 More about the HBox, VBox , and GridPane Layout Containers 776























The HBox Layout Container 777
The VBox Layout Container 782
The GridPane Layout Container 784
Using Multiple Layout Containers in the Same Screen 791
12.6 Button Controls and Events 792
Handling Events 794
Writing Event Handlers 794
Registering an Event Handler 795
12.7 Reading Input with TextField Controls 799
12.8 Using Anonymous Inner Classes and Lambda Expressions to Handle Events
803
Using Anonymous Inner Classes to Create Event Handlers 803
Using Lambda Expressions to Create Event Handlers 806
12.9 The BorderPane Layout Container 808
12.10 The ObservableList Interface 812
12.11 Common Errors to Avoid 814
Review Questions and Exercises 814
Programming Challenges 818
Chapter 13 JavaFX: Advanced Controls 823
13.1 Styling JavaFX Applications with CSS 823
Type Selector Names 824
Style Properties 825
Applying a Stylesheet to a JavaFX Application 826






















Applying Styles to the Root Node 830
Specifying Multiple Selectors in the Same Style Definition 832
Working with Colors 832
Creating a Custom Style Class Name 834
ID Selectors 836
Inline Style Rules 837
13.2 RadioButton Controls 838
Determining in Code Whether a RadioButton Is Selected 839
Selecting a RadioButton in Code 839
Responding to RadioButton Clicks 844
13.3 CheckBox Controls 848
Determining in Code Whether a CheckBox Is Selected 848
Selecting a CheckBox in Code 849
Responding to CheckBox Clicks 853
13.4 ListView Controls 853
Retrieving the Selected Item 855
Retrieving the Index of the Selected Item 856
Responding to Item Selection with an Event Handler 859
Adding Items versus Setting Items 860
Initializing a ListView with an Array or an ArrayList 861
Selection Modes 862
Retrieving Multiple Selected Items 863






















Working With the Elements of an ObservableList 866
Converting an ObservableList to an Array 867
Using Code to Select an Item in a ListView 868
ListView Orientation 868
Creating ListViews of Objects Other Than String 869
13.5 ComboBox Controls 874
Retrieving the Selected Item 875
Responding to ComboBox Item Selection with an Event Handler 877
Editable ComboBoxes 879
13.6 Slider Controls 880
13.7 TextArea Controls 885
13.8 Menus 887
Assigning Mnemonics to Menu Items 895
13.9 The FileChooser Class 897
Displaying a FileChooser Dialog Box 898
13.10 Using Console Output to Debug a GUI Application 898
13.11 Common Errors to Avoid 902
Review Questions 902
Programming Challenges 906
Chapter 14 JavaFX: Graphics, Effects, and Media 909
14.1 Drawing Shapes 909
The Screen Coordinate System 909
The Shape Class and Its Subclasses 910























The Line Class 911
Changing the Stroke Color 914
The Circle Class 914
The Rectangle Class 918
The Ellipse Class 921
The Arc Class 924
The Polygon Class 928
The Polyline Class 931
The Text Class 933
Rotating Nodes 936
Scaling Nodes 938
14.2 Animation 940
The TranslateTransition Class 941
The RotateTransition Class 944
The ScaleTransition Class 949
The StrokeTransition Class 952
The FillTransition Class 953
The FadeTransition Class 954
Controlling the Animation 956
Specifying an Interpolator 956
14.3 Effects 958
The DropShadow Class 958






















The InnerShadow Class 961
The ColorAdjust Class 962
The BoxBlur , GaussianBlur , and MotionBlur Classes 962
The SepiaTone Class 965
The Glow Class 966
The Reflection Class 967
Combining Effects 967
14.4 Playing Sound Files 969
Registering an EndOfMedia Event Handler 971
14.5 Playing Videos 974
14.6 Handling Key Events 979
Using an Anonymous Inner Class to Register a Key Event Handler to the Scene
980
Using a Lambda Expression to Register a Key Event Handler to the Scene 981
14.7 Handling Mouse Events 986
14.8 Common Errors to Avoid 992
Review Questions 992
Programming Challenges 995
Chapter 15 Recursion 999
15.1 Introduction to Recursion 999
15.2 Solving Problems with Recursion 1002
Direct and Indirect Recursion 1006
15.3 Examples of Recursive Methods 1007






















Summing a Range of Array Elements with Recursion 1007
Drawing Concentric Circles 1008
The Fibonacci Series 1011
Finding the Greatest Common Divisor 1012
15.4 A Recursive Binary Search Method 1014
15.5 The Towers of Hanoi 1017
15.6 Common Errors to Avoid 1021
Review Questions and Exercises 1022
Programming Challenges 1025
Chapter 16 Databases 1027
16.1 Introduction to Database Management Systems 1027
JDBC 1028
SQL 1029
Using a DBMS 1029
Java DB and Apache Derby 1030
Creating the CoffeeDB Database 1030
Connecting to the CoffeeDB Database 1030
Connecting to a Password-Protected Database 1032
16.2 Tables, Rows, and Columns 1033
Column Data Types 1035
Primary Keys 1035
16.3 Introduction to the SQL SELECT Statement 1036
Passing an SQL Statement to the DBMS 1038























Specifying Search Criteria with the WHERE Clause 1048
Sorting the Results of a SELECT Query 1054
Mathematical Functions 1055
16.4 Inserting Rows 1058
Inserting Rows with JDBC 1060
16.5 Updating and Deleting Existing Rows 1062
Updating Rows with JDBC 1063
Deleting Rows with the DELETE Statement 1067
Deleting Rows with JDBC 1067
16.6 Creating and Deleting Tables 1071
Removing a Table with the DROP TABLE Statement 1074
16.7 Creating a New Database with JDBC 1074
16.8 Scrollable Result Sets 1076
16.9 Result Set Metadata 1077
16.10 Relational Data 1084
Joining Data from Multiple Tables 1086
An Order Entry System 1087
16.11 Advanced Topics 1100
Transactions 1100
Stored Procedures 1101
16.12 Common Errors to Avoid 1102
Review Questions and Exercises 1102
Programming Challenges 1107























Index 1109
The following appendices, online chapters, and online case studies are available on the
book’s online resource page at www.pearson.com/cs-resources.
Online Appendices:
Appendix A: The ASCII/Unicode Characters
Appendix B: Operator Precedence and Associativity
Appendix C: Java Key Words
Appendix D: Installing the JDK and Using the JDK Documentation
Appendix E: Using the javadoc Utility
Appendix F: More about the Math Class
Appendix G: Packages
Appendix H: Working with Records and Random - Access Files
Appendix I: Configuring Java DB and Installing Apache Derby
Appendix J: The QuickSort Algorithm
Appendix K: Named Colors
Appendix L: Answers to Checkpoints
Appendix M: Answers to Odd-Numbered Review Questions
Online Chapters:
Chapter 17: A First look at GUI Applications
Chapter 18: Advanced GUI Applications
Chapter 19: Applets and More
Chapter 20: Creating GUI Applications with JavaFX and Scene Builder


















Online Case Studies:
Case Study 1: Calculating Sales Commission
Case Study 2: The Amortization Class
Case Study 3: The PinTester Class
Case Study 4: Parallel Arrays
Case Study 5: The FeetInches Class
Case Study 6: The SerialNumber Class
Case Study 7: A Simple Text Editor Application







Location of videonotes in the text
Chapter
1
Compiling and Running a Java Program, p. 14
Using an IDE, p. 14
Your First Java Program, p. 25
Chapter
2
Displaying Console Output, p. 33
Declaring Variables, p. 39
Simple Math Expressions, p. 55
The Miles-per-Gallon Problem, p. 107
Chapter
3
The if Statement, p. 111
The if-else Statement, p. 120
The if-else-if Statement, p. 129
The Time Calculator Problem, p. 182
Chapter
4
The while Loop, p. 193
The Pennies for Pay Problem, p. 263




Chapter
5
Passing Arguments to a Method, p. 279
Returning a Value from a Method, p. 293
The Retail Price Calculator Problem, p. 311
Chapter
6
Writing Classes and Creating Objects, p. 325
Initializing an Object with a Constructor, p. 346
The Personal Information Class Problem, p. 395
Chapter
7
Accessing Array Elements in a Loop, p. 407
Passing an Array to a Method, p. 422
The Charge Account Validation Problem, p. 487
Chapter
8
Returning Objects from Methods, p. 503
Aggregation, p. 515
The BankAccount , Class Copy Constructor Problem,
p. 552




Chapter
9
The Sentence Capitalizer Problem, p. 605
Chapter
10
Inheritance, p. 611
Polymorphism, p. 655
The Employee and Productionworker Classes
Problem, p. 696
Chapter
11
Handling Exceptions, p. 701
The Exception Project Problem, p. 757
Chapter
12
Introduction to JavaFX, p. 762
Creating Scenes, p. 765
Displaying Images, p. 772
The HBox Layout Container, p. 777
The VBox Layout Container, p. 782
The GridPane Layout Container, p. 784
Button Controls and Events, p. 792




The TextField Control, p. 799
Using Anonymous Inner Classes as Event Handlers, p.
803
Using Lambda Expressions as Event Handlers, p. 806
The Latin Translator Problem, p. 818
Chapter
13
JavaFX and CSS, p. 823
RadioButton Controls, p. 838
CheckBox Controls, p. 848
ListView Controls, p. 853
ComboBox Controls, p. 874
Slider Controls, p. 880
The Dorm and Meal Plan Calculator Problem, p. 906
Chapter
14
Drawing Shapes with JavaFX, p. 909
JavaFX Animation, p. 940
JavaFX Effects, p. 958


Playing Sound Files with JavaFX, p. 970
Playing Videos with JavaFX, p. 974
Handling Key Events in JavaFX, p. 979
Handling Mouse Events in JavaFX, p. 986
The Coin Toss Problem, p. 996
Chapter
15
Reducing a Problem with Recursion, p. 1003
The Recursive Power Problem, p. 1026
Chapter
16
The Customer Inserter Problem, p. 1107


Preface
Welcome to Starting Out with Java: From Control Structures through Objects,
Seventh Edition. This book is intended for a one-semester or a two-
quarter CS1 course. Although it is written for students with no prior
programming background, even experienced students will benefit from
its depth of detail.
Control Structures First, Then Objects
This text first introduces the student to the fundamentals of data types,
input and output, control structures, methods, and objects created from
standard library classes.
Next, the student learns to use arrays of primitive types and reference
types. After this, the student progresses through more advanced topics,
such as inheritance, polymorphism, the creation and management of
packages, GUI applications, recursion, and database programming. From
early in the book, applications are documented with javadoc comments.
As the student progresses through the text, new javadoc tags are covered
and demonstrated.
As with all the books in the Starting Out With … series, the hallmark of
this text is its clear, friendly, and easy-to-understand writing. In addition,
it is rich in example programs that are concise and practical.
Changes in the Seventh Edition
This book’s pedagogy, organization, and clear writing style remain the
same as in the previous edition. The most significant change in this
edition is the switch from Swing to JavaFX in the chapters that focus on
GUI development. Although Swing is not officially deprecated, Oracle has
announced that JavaFX has replaced Swing as the standard GUI library
for Java.
http://www.oracle.com/technetwork/java/javafx/overview/faq-1446554.html#6
In this edition, we have added the following new chapters:
CHAPTER 12 JAVAFX: GUI PROGRAMMING AND BASIC
CONTROLS This chapter presents the basics of developing graphical
user interface (GUI) applications with JavaFX. Fundamental controls,
layout containers, and the basic concepts of event-driven
programming are covered.
CHAPTER 13 JAVAFX: ADVANCED CONTROLS This chapter
discusses CSS styling and advanced user interface controls.
CHAPTER 14 JAVAFX: GRAPHICS, EFFECTS, AND MEDIA This
chapter discusses 2D shapes, animation, visual effects, playing audio
and video, and responding to mouse and keyboard events.
The Swing and Applet material that appeared in the previous edition is
still available on the book’s companion Web site, as the following online
chapters:
The previous Chapter 12 A First Look At GUI Applications is now
available online as Chapter 17 .
The previous Chapter 13 Advanced GUI Applications is now available
online as ­
Chapter 18 .
1
1







The previous Chapter 14 Applets and More is now available online as
Chapter 19 .
Note: Chapter 15 from the previous edition has also been moved to the
book’s companion Web site as Chapter 20 Creating JavaFX Applications
with Scene Builder. Although Oracle no longer officially supports Scene
Builder, it is still available as an open source tool at
http://http://gluonhq.com/labs/scene-builder/
In addition to the new JavaFX chapters, the Database chapter, which is
now Chapter 15 , has been updated to use JavaFX instead of Swing for
its GUI applications. We have also added several new, motivational
programming problems throughout the book.
Organization of the Text
The text teaches Java step-by-step. Each chapter covers a major set of
topics and builds knowledge as students progress through the book.
Although the chapters can be easily taught in their existing sequence,
there is some flexibility. Figure P-1 shows chapter dependencies. Each
box represents a chapter or a group of chapters. An arrow points from a
chapter to the chapter that must be previously covered.






Figure P-1 Chapter dependencies
Brief Overview of Each Chapter
Chapter 1 : Introduction to Computers and Java.
This chapter provides an introduction to the field of computer science and
covers the fundamentals of hardware, software, and programming
languages. The elements of a program, such as key words, variables,
operators, and punctuation, are discussed by examining a simple
program. An overview of entering source code, compiling, and executing
a program is presented. A brief history of Java is also given.
Chapter 2 : Java Fundamentals.
This chapter gets students started in Java by introducing data types,
identifiers, variable declarations, constants, comments, program output,
and simple arithmetic operations. The conventions of programming style
are also introduced. Students learn to read console input with the
Scanner class and with dialog boxes using JOptionPane .
Chapter 3 : Decision Structures.
In this chapter students explore relational operators and relational
expressions and are shown how to control the flow of a program with the
if , if-else , and if-else-if statements. Nested if statements,
logical operators, the conditional operator, and the switch statement are
also covered. The chapter discusses how to compare String objects
with the equals , compareTo , equalsIgnoreCase , and
compareToIgnoreCase methods. Formatting numeric output with the
System.out.printf method and the String.format method is
discussed.



Chapter 4 : Loops and Files.
This chapter covers Java’s repetition control structures. The while
loop , do-while loop , and for loop are taught, along with
common uses for these devices. Counters, accumulators, running totals,
sentinels, and other application-related topics are discussed. Simple file
operations for reading and writing text files are included.
Chapter 5 : Methods.
In this chapter students learn how to write void methods, value-returning
methods, and methods that do and do not accept arguments. The concept
of functional decomposition is discussed.
Chapter 6 : A First Look at Classes.
This chapter introduces students to designing classes for the purpose of
instantiating objects. Students learn about class fields and methods, and
UML diagrams are introduced as a design tool. Then constructors and
overloading are discussed. A BankAccount class is presented as a case
study, and a section on object-oriented design is included. This section
leads the students through the process of identifying classes and their
responsibilities within a problem domain. There is also a section that
briefly explains packages and the import statement.
Chapter 7 : Arrays and the ArrayList Class.
In this chapter students learn to create and work with single and multi-
dimensional arrays. Numerous array-processing techniques are
demonstrated, such as summing the elements in an array, finding the
highest and lowest values, and sequentially searching an array. Other
topics, including ragged arrays and variable-length arguments (varargs),
are also discussed. The ArrayList class is introduced, and Java’s
generic types are briefly discussed and demonstrated.




Chapter 8 : A Second Look at Classes and Objects.
This chapter shows students how to write classes with added capabilities.
Static methods and fields, interaction between objects, passing objects as
arguments, and returning objects from methods are discussed.
Aggregation and the “has a” relationship is covered, as well as
enumerated types. A section on object-oriented design shows how to use
CRC cards to determine the collaborations among classes.
Chapter 9 : Text Processing and More about
Wrapper Classes.
This chapter discusses the numeric and Character wrapper classes.
Methods for converting numbers to strings, testing the case of characters,
and converting the case of characters are covered. Autoboxing and
unboxing are also discussed. More String class methods are covered,
including using the split method to tokenize strings. The chapter also
covers the StringBuilder class.
Chapter 10 : Inheritance.
The study of classes continues in this chapter with the subjects of
inheritance and polymorphism. The topics covered include superclasses,
subclasses, how constructors work in inheritance, method overriding,
polymorphism and dynamic binding, protected and package access, class
hierarchies, abstract classes, abstract methods, anonymous inner classes,
interfaces, and lambda expressions.



Another Random Document on
Scribd Without Any Related Topics
behaves in the same manner. Wheat flour, made into a paste with
water, and left for four or five days in a warm situation, becomes a
true lactic acid ferment; but if left a day or two longer, it changes its
character, and then acts like common yeast, occasioning the ordinary
panary or vinous fermentation. Moist animal membranes, in a
slightly decaying condition, often act energetically in developing
lactic acid. The rennet employed in the manufacture of cheese
furnishes a well-known example of this class of substances.
In preparing lactic acid from milk, the acid formed, after a time,
coagulates and renders insoluble the casein, and the production of
the acid ceases. By carefully neutralising the free acid by carbonate
of sodium, the casein becomes soluble, and resuming its activity,
changes a fresh quantity of sugar into lactic acid, which may be also
neutralised, and by a sufficient number of repetitions of this process
all the sugar of milk present may, in time, be acidified. This is the
rationale of the common process by which lactic acid is obtained.
Cane-sugar (probably by previously becoming grape-sugar) and the
sugar of milk both yield lactic acid; the latter, however, most readily,
the grape-sugar having a strong tendency towards the alcoholic
fermentation. If the lactic fermentation be allowed to proceed too
far, the second stage of the process of transmutation commences,
hydrogen gas and carbonic acid gas are evolved, and the butyric
fermentation, by which oily acids are formed, is established.
Pasteur ascribes the lactic fermentation to the agency of a
specific kind of ferment, which occurs in the form of a greyish layer
deposited upon the surface of the sediment formed during the
fermentation of the sugar, casein, and chalk (see Lactic acid, b), in
the manufacture of lactic acid.
If to a mixture of yeast, or any nitrogenous substance, and
water, sugar, and then chalk, be added, and finally a very small
quantity of this greyish substance, taken from a portion of a liquid
undergoing active lactic fermentation, lactic acid fermentation is
almost immediately set up, the chalk disappears owing to the
formation of calcic lactate, and the greyish substance is copiously
deposited. When placed under the microscope this ferment is seen
to be composed of “little globules, or very short articulations, either
isolated or in threads, constituting irregular flocculent particles,
much smaller than those of beer yeast, and exhibiting a rapid
gyratory motion.” If these little particles be washed thoroughly in
pure water, and then placed in a solution of sugar, lactic acidification
immediately commences in the saccharine liquid, and goes on
steadily until stopped by the excess of free acid.
LAC′TIDE. See Lactic acid.
LAC′TIN. See Sugar of Milk.
LAC′TOMETER. Syn. Galactometer. An instrument for
ascertaining the quality of milk. Milk may be roughly tested by
placing it in a long graduated tube sold for the purpose, and
allowing it to remain until all the cream has separated and
measured, then decanting off the clear whey, and taking its specific
gravity; the result of the two operations, when compared with the
known quantity of cream and the density of the whey of an average
sample of milk, gives the value of the sample tested. See Milk.
A little instrument called a ‘milk-tester’ is sold in London at a low
price. It is essentially a hydrometer which sinks to a given mark on
the stem in pure water, and floats at another mark at the opposite
end of the scale in pure milk. The intermediate space indicates the
quantity of water (if any) employed to adulterate the article. As the
sp. gr. of pure milk varies, the indications of the ‘tester’ cannot be
depended on.
LAC′TOSE. See Sugar of Milk.
LAC′TUCA. (B. P.) Syn. Lettuce. The leaves and flowering tops
of the wild indigenous plant Lactuca virosa. They are sedative,
narcotic, and powerfully diuretic; also mildly laxative and diaphoretic.
Given in dropsy and visceral obstructions. See Lettuce, Extract of.
LACTUCA′′RIUM. Syn. Lettuce opium. Thridace; Lactucarium (Ph.
E. & D.). The inspissated milky juice of the Lactuca sativa (common
garden lettuce), or the Lactuca virosa (strong-scented wild lettuce),
obtained, by incision, from the flowering stems, and dried in the air.
The latter species yields by far the greatest quantity. M. Arnaud, of
Nancy, adopts the following method of procuring this substance,
which appears to be the most productive and simple of any yet
published:—Before the development of the lateral branches, the
stems of twelve plants are cut, one after another, a little below the
commencement of these branches; returning to the first one, a milky
exudation is found on the cut portion, and on that which remains
fixed in the earth; this milky exudation is adroitly collected with the
end of the finger (or with a bone knife), which is afterwards scraped
on the edge of a small glass; the same operation is performed on
twelve other heads, and so on; on the third day it is repeated on
every portion of the plant remaining in the ground, a thin slice being
first cut off the top; this is done every day until the root is reached.
As soon as the lactucarium is collected it coagulates; the harvest of
each day is divided into small pieces, which are placed on plates,
very near each other, but without touching, and allowed to dry for
two days, after which they are set aside in a bottle. In this way 15 or
20 times the ordinary product is obtained.
Prop., &c. Lactucarium is anodyne, hypnotic, antispasmodic, and
sedative, allaying pain and diminishing the force of the circulation. It
has been recommended in cases in which opium is inadmissible, and
has been administered with advantage in chronic rheumatism, colic,
diarrhœa, asthma, and troublesome cough of phthisis, the irritability
and watchfulness in febrile disorders, &c.—Dose, 2 to 5 gr.; made
into pills, lozenges, or tincture.
LACTU′CIN. Syn. Lactucinum, L. This is the active principle of
lactucarium, and is found in the juice of several species of lettuce.
Prep. Exhaust lactucarium with hot rectified spirit, agitate the
tincture with a little animal charcoal, filter, add a little milk of lime,
and evaporate to dryness; digest the residuum in hot rectified spirit;
filter, and evaporate by a gentle heat, so that crystals may form.
Prop., &c. A nearly colourless, odourless, fusible, neutral, bitter
substance; sparingly soluble in cold water and in ether, but freely
soluble in alcohol. It possesses feeble basic properties. Good
lactucarium contains fully 20% of this substance.
LAD′ANUM. See Labdanum.
LAENNEC’S CONTRA-STIMULANT. See Draught.
LAKE. Syn. Lacca, L. Animal or vegetable colouring matter,
precipitated in combination with oxide of tin or alumina; usually the
latter. The term was formerly restricted to red preparations of this
kind, but is now indiscriminately applied to all compounds of alumina
and colouring matter. The term ‘LAKE,’ when unqualified by an
adjective, is, however, understood to apply exclusively to that
prepared from cochineal.
Prep. Lakes are made—1. By adding a solution of alum, either
alone or partly saturated with carbonate of potassa, to a filtered
infusion or decoction of the colouring substance, and after agitation
precipitating the mixture with a solution of carbonate of potash.—2.
By precipitating a decoction or infusion of the colouring substance
made with a weak alkaline lye, by adding a solution of alum.—3. By
agitating recently precipitated alumina with a solution of the
colouring matter, prepared as before, until the liquid is nearly
decoloured, or the alumina acquires a sufficiently dark tint. The first
method is usually employed for acidulous solutions of colouring
matter, or for those whose tint is injured by alkalies; the second, for
those that are brightened, or at least uninjured, by alkalies; the
third, for those colouring matters that have a great affinity for
gelatinous alumina, and readily combine with it by mere agitation.
By attention to these general rules, lakes may be prepared from
almost all animal and vegetable colouring substances that yield their
colour to water, many of which will be found to possess great beauty
and permanence. The precise process adapted to each particular
substance may be easily ascertained by taking a few drops of its
infusion or decoction, and observing the effects of alkalies and acids
on the colour. The quantity of alum or of alumina employed should
be nearly sufficient to decolour the dye liquor; and the quantity of
carbonate of potassa should be so proportioned to the alum as to
exactly precipitate the alumina without leaving free or carbonated
alkali in the liquid. The first portion of the precipitate has the
deepest colour, and the shade gradually becomes paler as the
operation proceeds. A beautiful ‘tone’ of violet, red, and even purple,
may be communicated to the colouring matter of cochineal by the
addition of perchloride of tin; the addition of arseniate of potassa
(neutral arsenical salt) in like manner gives shades which may be
sought for in vain with alum or alumina. After the lake is
precipitated, it must be carefully collected, washed with cold distilled
water, or the purest rain water, until it ceases to give out colour, and
then carefully dried in the shade. In this state it forms a soft velvety
powder. That of the shops is generally made up into conical or
pyramidal drops (drop lake), which is done by dropping the moist
lake through a small funnel on a clean board or slab, and drying it by
a gentle heat as before. A very little clear gum water is commonly
added to the paste to give the drops consistence when dry.
Lake, Blue. Syn. Lacca cœrulea, L. Prepared from some of the
blue-coloured flowers; fugitive. The name is also applied to lump
archil (lacca cœrulea), to moist alumina coloured with indigo, and to
mixed solutions of pearlash and prussiate of potash, precipitated
with another solution of sulphate of iron and alum. These are
permanent and beautiful, but are seldom used, in consequence of
indigo and Prussian blue supplying all that is wanted in this class of
colours.
Lake, Brazil-wood. Syn. Drop lake; Lacca in globulis, L. Prep. 1.
Take of ground Brazil-wood, 1 lb.; water, 4 galls.; digest for 24
hours, then boil for 30 or 40 minutes, and add of alum, 11⁄2 lb.,
dissolved in a little water; mix, decant, strain, and add of solution of
tin, 1⁄2 lb.; again mix well and filter; to the clear liquid add,
cautiously, a solution of salt of tartar or carbonate of soda, as long
as a deep-coloured precipitate forms, carefully avoiding excess;
collect, wash, dry, &c., as directed above.
Obs. The product is deep red. By collecting the precipitate in
separate portions, lakes varying in richness and depth of colour may
be obtained. The first portion of the precipitated lake has the
brightest colour. An excess of alkali turns it on the violet, and the
addition of cream of tartar, on the brownish red. The tint turns more
on the violet red when the solution of tin is omitted. Some persons
use less, others more, alum.
2. Add washed and recently precipitated alumina to a strong
and filtered decoction of Brazil wood. Inferior to the last.
Lake, Carminated. Syn. Cochineal lake, Florence l., Florentine l.,
Paris l., Vienna l.; Lacca Florentina, L. Prep. 1. The residuum of the
cochineal left in making carmine is boiled with repeated portions of
water, until it is exhausted of colour; the resulting liquor is mixed
with that decanted off the carmine, and at once filtered; some
recently precipitated alumina is then added, and the whole gently
heated, and well agitated for a short time; as soon as the alumina
has absorbed sufficient colour, the mixture is allowed to settle, after
which the clear portion is decanted, the lake collected on a filter,
washed, and dried, as before. The decanted liquor, if still coloured, is
now treated with fresh alumina until exhausted, and thus a lake of a
second quality is obtained. Very fine.
2. To the coloured liquor obtained from the carmine and
cochineal as above, a solution of alum is added, the filtered liquor
precipitated with a solution of carbonate of potassa, and the alum or
alumina; this brightens the lake collected and treated as before.
Scarcely so good as the last.
Obs. Some makers mix a little solution of tin with the coloured
liquor before adding colour. The above lake is a good glazing colour
with oil, but has little body. It may be made directly from a decoction
of cochineal. (See below.)
Lake, Cochineal. Prep. 1. Cochineal (in coarse powder), 1 oz.;
water and rectified spirit, of each 21⁄2 oz.; digest for a week, filter,
and precipitate the tincture with a few drops of solution of tin, added
every two hours, until the whole of the colouring matter is thrown
down; lastly, wash the precipitate in distilled water, and dry it. Very
fine.
2. Digest powdered cochineal in ammonia water for a week,
dilute the solution with a little water, and add the liquid to a solution
of alum, as long as a precipitate falls, which is the lake. Equal to the
last.
3. Coarsely powdered cochineal, 1 lb.; water, 2 galls.; boil 1
hour, decant, strain, add a solution of salt of tartar, 1 lb., and
precipitate with a solution of alum. By adding the alum first, and
precipitating the lake with the alkali, the colour will be slightly
varied. All the above are sold as CARMINATED or Florence lake, to
which they are often superior.
Lake, Green. Made by mixing blue and yellow lake together.
Seldom kept in the shops, being generally prepared
extemporaneously by the artist on his palette.
Lake, Lac. Prep. Boil fresh stick-lac in a solution of carbonate
of soda, filter the solution, precipitate with a solution of alum, and
proceed as before.
Lake, Lichen. See Orcein.
Lake, Madder. Syn. Lacca rubiæ, L. columbina, L. Prep. 1. (Sir H.
C. Inglefield.) Take of Dutch grappe or crop madder, 2 oz.; tie it in a
cloth, beat it well in a pint of water in a stone mortar, and repeat the
process with fresh water (about 5 pints) until it ceases to yield
colour; next boil the mixed liquor in an earthen vessel, pour it into a
large basin, and add of alum 1 oz., previously dissolved in boiling
water, 1 pint; stir well, and while stirring, pour in gradually of a
strong solution of carbonate of potassa (‘oil of tartar’), 11⁄2 oz.; let
the whole stand until cold, then pour off the supernatant yellow
liquor, drain, agitate the residue with boiling water, 1 quart (in
separate portions), decant, drain, and dry. Product, 1⁄2 oz. The
Society of Arts voted their gold medal to the author of the above
formula.
2. Add a little solution of acetate of lead to a decoction of
madder, to throw down the brown colouring matter, filter, add a
solution of tin or alum, precipitate with a solution of carbonate of
soda or of potassa, and otherwise proceed as before.
3. (Ure.) Ground madder, 2 lbs.; water, 1 gall.; macerate with
agitation for 10 minutes, strain off the water, and press the
remainder quite dry; repeat the process a second and a third time;
then add to the mixed liquors, alum 1⁄2 lb., dissolved in water, 3
quarts; and heat in a water bath for 3 or 4 hours, adding water as it
evaporates; next filter, first through flannel, and, when sufficiently
cold, through paper; then add a solution of carbonate of potassa as
long as a precipitate falls, which must be washed until the water
comes off colourless, and, lastly, dried. If the alkali be added in 3
successive doses, 3 different lakes will be obtained, successively
diminishing in beauty. See Madder, Madder, Red, &c.
Lake, Or′ange. Prep. Take of the best Spanish annotta, 4 oz.;
pearlash, 3⁄4 lb.; water, 1 gall.; boil for half an hour, strain,
precipitate with alum, 1 lb., dissolved in water, 1 gall., observing not
to add the latter solution when it ceases to produce an effervescence
or a precipitate; strain, and dry the sediment in small squares,
lozenges, or drops. The addition of some solution of tin turns this
lake on the LEMON YELLOW; acids redden it. See Lake, Yellow.
Lake, Red. Prep. Take of pearlash, 1 lb.; clean shreds of scarlet
cloth, 31⁄2 lbs.; water, 5 galls.; boil till the cloth is decoloured, filter
the decoction, and precipitate with a solution of alum, as before. See
the Lakes noticed above (Brazil-wood, Carminated, Cochineal, and
Madder).
Lake, Yellow. Prep. 1. Boil French berries, quercitron bark, or
turmeric, 1 lb., and salt of tartar, 1 oz., in water, 1 gall., until reduced
to one half, then strain the decoction, and precipitate with a solution
of alum.
2. Boil 1 lb. of the dye-stuff with alum, 1⁄2 lb.; water, 1 gall., as
before, and precipitate the decoction with a solution of carbonate of
potash. See Lake, Orange (above).
LAMB in its general qualities closely resembles mutton, of
which, indeed, it is merely a younger and more delicate kind. It is
well adapted as an occasional article of food for the convalescent
and dyspeptic; but it is unequal for frequent use, more especially for
the healthy and robust, to the flesh of the adult animal.
LAMBS, DISEASES OF. Among other diseases, these animals
are particularly prone to one affecting the lungs, in consequence of
the existence of parasites (Strongylus bronchialis) in the air-
passages. See Parasites.
LAMP. A contrivance for producing artificial light or heat by the
combustion of inflammable liquids. The term ‘lamp’ is also applied to
a portable gas-burner (GAS-LAMP), and to a tubular candle-holder,
which, by the aid of a simple mechanical device, keeps the flame at
one height (CANDLE-LAMP).
Oil lamps were employed for illumination among the nations of
antiquity, at the earliest period of which any record exists. The
Assyrian, Greek, and Roman lamps preserved in our museums are
generally noble specimens of art-workmanship. Though elegant in
form, and rich in external embellishment, the ancient lamp was
simply a vessel to contain the oil, with a short depression or spout
on the one side, in which the wick is laid. Lamps of this rude
construction are still in common use in many countries.
No important improvement in the principle and construction of
lamps as a source of light occurred until a comparatively recent
date; the smoke, dirt, and disagreeable odour of the common lamp
having previously led to its disuse among the superior classes in
favour of candles. At length, in 1789, M. Argand made a revolution
in illumination by the invention and introduction of the well-known
lamp which bears his name. In the Argand lamp a hollow tubular wick
of woven cotton replaces the solid bundles of fibres, and is so
arranged that air passes through it into the interior of the flame.
Over the burner is placed a cylindrical glass chimney, open at the
bottom, and surrounding the flame at a short distance from it, by
which another current of air is made to act on the exterior portion of
the flame. In this way a due supply of oxygen is secured, and
sufficient heat generated for the perfect combustion of the gaseous
products of the oil, and the smoke and soot which escape from the
ordinary lamp are converted into a brilliant and smokeless flame.
The earliest table-lamps constructed on Argand’s principle had
one serious defect—the oil vessels had to be placed almost on a
level with the burners, in a position which caused them to cast
objectionable shadows. This defect was almost entirely removed by
making the oil vessel in the form of a flattish ring, connected by
slender tubes with the burner. The more elegant contrivances,
known as the MODERATOR LAMP and Carcel lamp, which are now so
much used for burning colza and similar oils, cast no shadow. In
these the oil, instead of being sucked up by the wick, or descending
to it by the force of gravity, is driven up by mechanical means from
the oil-reservoir contained in the foot or pedestal. A spiral spring,
acting upon a piston, elevates the oil in the ‘moderator,’ while a little
pump worked by clockwork does the same duty in the ‘Carcel.’ The
burner and wick in each are formed on Argand’s principle.
For burning the hydrocarbon oils distilled from coal and
petroleum, lamps of very simple construction are used. These oils, in
consequence of their diffusive character, rise to a considerable height
up a wick, and therefore do not require mechanical lamps. The wicks
of HYDRO-CARBON LAMPS are usually flat, but sometimes circular. To
cause perfect combustion, a strong draught of air is created by
placing over the flame a tall glass chimney, usually much contracted
above the flame. A metallic cap, with an orifice the shape of the
flame, is placed over the burner, its use being to deflect the currents
of air upon the flame. The reservoirs of hydro-carbon lamps ought
always to be constructed of some bad conductor of heat, as glass or
porcelain.
For chemical operations, many forms of lamp are used. The
ordinary glass SPIRIT-LAMP, fitted with a ground-glass cap, is quite
indispensable for minor experiments. (See engr. 1.) Stoneware wick-
holders are preferable to those of brass, which become greatly
heated, and endanger the splitting of the glass. “An effective spirit-
lamp may at any time be constructed out of a vial having a glass
tube passing through the cork, a cover being formed from a test-
tube inverted over the wick, and fitting with moderate tightness on
the superior extremity of the cork” (Greville Williams). Alcohol or
wood spirit is the fuel used.
The Argand lamp, when intended as a source of heat for chemical
purposes, is so modified as to adapt it to burn either oil, spirit of
wine, or wood-spirit, and the combustion is greatly aided by the
chimney, which in this case is made of copper. (See engr. 2 and 3.)
The lamp itself is also made of metal, and furnished with ground
caps to the wick-holder and aperture by which the spirit is
introduced, in order to prevent loss of spirit by evaporation when the
lamp is not in use. When in use this aperture must always be left
open, otherwise an accident is sure to happen, as the heat expands
the air in the lamp, and the spirit is forcibly expelled.
In those situations in which coal-gas is cheap, it may be used
with great economy and advantage as a source of heat in most
chemical operations. Retorts, flasks, capsules, and other vessels, can
be thus exposed to an easily regulated and constant temperature for
many successive hours. Small platinum crucibles may be ignited to
redness by placing them over the flame on a little wire triangle. Of
the various gas-lamps now used in the laboratory, the first and most
simple consists of a common Argand gas-burner fixed on a heavy
and low foot, and connected with a flexible gas-tube of caoutchouc
or other material. (See engr. 4.) With this arrangement it is possible
to obtain any degree of heat, from that of the smallest blue flame to
that which is sufficient to raise a moderately large platinum crucible
to dull redness. When gas mixed with a certain proportion of air is
burnt, a pale blue flame, free from smoke, and possessing great
heating power, is obtained. A lamp for burning the mixture may
easily be made by fitting a close cover of fine wire gauze over the
top of the chimney of the last-mentioned contrivance. The gas is
turned on, and after a few minutes ignited above the wire gauze.
(See page 946). The ingenious and useful burners of Bunsen and
Griffin are so constructed that gas and air mixed in any proportions,
or gas alone, may be burnt at pleasure. Bunsen’s is a most efficient
and convenient form of burner. (See illustration on next page.) It
consists of a gas jet, surrounded by a metal tube, about 6 to 9
inches high and about 1⁄2 inch in diameter; having at the bottom
four large holes. On the admission of air, when the gas is turned on,
the air rushes in by these orifices, and mingling with the gas, the
mixture ascends to the top of the tube and is there ignited, giving
rise to a flame of great heat, but without luminosity, owing to the
simultaneous combustion of the carbon and the hydrogen. The
burner, however, is so contrived that by shutting off the supply of air
entirely, or limiting it, the flame may be made more or less luminous
at pleasure. To distribute the flame, a rosette burner is placed on the
top of the tube.
An improved variety of this burner has been designed by
Bunsen, and is figured below.
Fig. 1.
Fig. 2.—Improved Bunsen burner.
It is so contrived as to give a flame that is a very much better
substitute for the flame of the blowpipe, than the ordinary Bunsen’s
burner, and may hence be employed for reducing, oxidising, fusing,
and volatilising, as well as for the observation of coloured flames.
Fig. 1 is a sheath which, by turning round, regulates the admission
of air. When it is used the conical chimney, d d d d, is placed in e e;
it is of a size sufficient to allow of the flame burning tranquilly. In fig.
1 the flame is represented of half its natural size. This flame it will
be seen consists of three divisions, viz.—1, a a a a the dark zone,
which is composed of cold gas mixed with about 62 per cent. of air.
2, a c a b the mantle formed by the burning mixture of gas and air.
3, a b a, the luminous tip of the dark cone, which only appears when
the orifices for the air are partially closed. Reductions may be
performed in this part of the flame.
Bunsen, however, divides the flame into six parts, to which he
attributes as many functions. These six divisions of the flame he
names as follows:—
1. The base at α has a relatively low temperature, because the
burning gas is here cooled by the constant current of fresh air, and
also because the lamp itself conducts the heat away. This part of the
flame serves for discovering the colours produced by readily volatile
bodies, when less volatile matters which colour the flame are also
present. At the relatively low temperature of this part of the flame,
the former vaporises alone instantaneously, and the resulting colour
imparted to the flame is for a moment visible unmixed with other
colours.
2. The Fusing Zone. This lies at β, at a distance from the bottom
of somewhat more than one third of the height of the flame,
equidistant from the outside and the inside of the mantle, which is
broadest at this part. This is the hottest part of the flame, viz., about
2300°, and it therefore serves for testing substances, as to their
fusibility, volatility, emission of light, and for all processes of fusion at
a high temperature.
3. The lower Oxidising Zone lies in the outer border of the
fusing zone at γ, and is especially suitable for the oxidation of oxides
dissolved in vitreous fluxes.
4. The upper Oxidising Flame at ε consists of the non-luminous
tip of the flame. Its action is strongest when the air holes of the
lamp are fully open. It is used for the roasting away of volatile
products of oxidation, and generally for all processes of oxidation,
when the highest temperature is not required.
5. The lower Reducing Zone lies at δ, in the inner border of the
fusing zone next to the dark cone. The reducing gases are here
mixed with oxygen, and, therefore, do not possess their full power,
hence they are without action on many substances which are
Argand’s lamp, with
wire-gauze cap.
deoxidised in the upper reducing flame. This part of the flame is
especially suited for reduction on charcoal or in vitreous fluxes.
6. The upper Reducing Flame lies at η, in the luminous tip of the
dark inner cone, which, as already explained, may be produced by
diminishing the supply of air. This part of the flame must not be
allowed to get large enough to blacken a test tube filled with water
and held in it. It contains no free oxygen, is rich in separated
incandescent carbon, and therefore has a much stronger action than
the lower reducing zone. It is used more particularly for the
reduction of metals collected in the form of incrustations.
The subjoined is a drawing of the gauze burner, which is an
open cylinder with wire gauze at the top.
When this is placed over the gas
burner, a supply of air is drawn in at the
bottom by the ascending current of gas,
and the mixture burns above the gauze,
with a very hot flame, quite free from
smoke, the metallic meshes preventing
the flame from passing down to the gas
below. See Illumination, Fuel, Furnace, Gas,
Laboratory, &c.
Lamp, Flame′less. Syn. Glow lamp. A
coil of fine platinum wire is slipped over
the wick of a spirit lamp, the greater part
being raised above the cotton; the lamp is
supplied with ether or alcohol, lighted for a moment and then blown
out. The coil continues to glow in the mixed atmosphere of air and
combustible vapour, until the liquid in the lamp is exhausted.
Lamp, Monochromat′ic. A lamp fed with a mixture of a
solution of common salt and spirit of wine. It gives a yellow light,
and makes every object illuminated by it appear either yellow or
black. The human features are changed in a remarkable degree; the
countenance appearing truly ghastly and unearthly.
Lamp, Safety. Syn. Miner’s lamp, Davy, Geordy. The safety lamp
of Sir H. Davy and George Stephenson are similar in principle, and
were independently invented about the same time. That of Sir H.
Davy consists of a common oil lamp, surmounted with a cylinder of
wire gauze, the apertures of which are not greater than the 1⁄20th
of an inch square, and the wire of which it is made to the 1⁄40th to
the 1⁄60th of an inch in diameter. (See engr.) The fire-damp
(carbonetted hydrogen) along with air passes through the meshes
into the interior of the gauze cylinder. Here it ignites, but the flame
which is produced by its combustion cannot explode a mixture of
fire-damp and air by which the lamp may be surrounded. The flame
is prevented from passing to the exterior of the gauze by the cooling
action of the metal of which it is constructed. When this lamp is
taken into an explosive atmosphere, although the fire-damp may
burn within the cage with such energy as sometimes to heat the
metallic tissue to dull redness, the flame is not communicated to the
mixture on the outside. These appearances are so remarkable, that
the lamp becomes an admirable indicator of the state of the air in
different parts of the mine, and if its admonitions are attended to,
gives the miner time to withdraw before an explosion takes place.
Lamp, Telescope. This ingenious contrivance, invented by
Messrs Murray and Heath, is intended for microscopic illumination. It
consists of three brass tubes, sliding one within the other, the oil
vessel being contained in the inner tube. The height of the lamp is
regulated to the greatest nicety by simply turning one tube in the
other, interior spiral guides preventing all chance of slipping. The
great advantage of this arrangement is absence of the stand and bar
usually employed for raising and lowering the lamp, which enables it
to be used on all sides, and to be brought much closer to the
microscope than other lamps. See engr., below.
LAMP BLACK. See Black pigments.
LAMP′REY. Syn. Great lamprey, Seal. This fish is the Petromizon
marinus of Linnæus. It generally quits the sea in the spring, for the
purpose of spawning, and remains in our rivers for a few months. Its
flesh is soft and glutinous, and though esteemed a delicacy, is
extremely difficult of digestion, if not otherwise unwholesome.
Potted lampreys are usually so highly seasoned as to become a
dangerous article of food. Henry I is said to have lost his life from
the effects of a surfeit of lampreys.
LAUDANINE. C20H25NO3. An alkaloid obtained by Hesse from
the aqueous extract of opium. It is homologous with morphine and
codeine. It dissolves in strong sulphuric acid with a rose-red colour,
in strong nitric acid with an orange red colour, and in ferric chloride
with emerald green colour.
LANTHA′NIUM. La92. A rare metal, discovered by Mosander,
associated with oxide of cerium. Oxide of lanthanium is a pale
salmon-coloured powder, unaffected by ignition in open vessels.
According to Zschiesche the atomic weight of lanthanium is 90·18.
See Cerium.
LANTHOPINE. C23H25NO4. A base obtained by Hesse in small
quantity, associated with other bases from the aqueous extract of
opium. It is homologous with papaverine. Strong nitric acid dissolves
it, giving rise to an orange red colour. Strong sulphuric acid gives
with it a faint violet colour.
LA′PIS. [L.] A stone. The term was much employed by the old
chemists, and is still commonly applied to several preparations used
in medicine.
Lapis Causticus. See Potassium.
Lapis Divi′nus. Syn. Divine Stone; Lapis ophthalmicus, L.; Pierre
divine, Fr. Prep. 1. (Beer.) Verdigris, nitre, and alum, equal parts,
melted together.
2. (P. Cod.) Alum, nitre, and blue vitriol, of each 3 oz.; camphor,
1 dr.; as last.
3. (Woolfuss.) Blue vitriol, nitre, alum, and camphor, equal
parts, melted together, adding the camphor last. Astringent and
detergent. 1 oz., dissolved in water, 1 pint, formed a once celebrated
lotion. 1 dr. in water, 1 pint, is still used as a collyrium.
Lapis Inferna′lis. See Nitrate of Silver.
Lapis Lazu′li. See Ultramarine.
Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.
More than just a book-buying platform, we strive to be a bridge
connecting you with timeless cultural and intellectual values. With an
elegant, user-friendly interface and a smart search system, you can
quickly find the books that best suit your interests. Additionally,
our special promotions and home delivery services help you save time
and fully enjoy the joy of reading.
Join us on a journey of knowledge exploration, passion nurturing, and
personal growth every day!
ebookbell.com

Starting Out With Java From Control Structures Through Objects 7e Tony Gaddis

  • 1.
    Starting Out WithJava From Control Structures Through Objects 7e Tony Gaddis download https://ebookbell.com/product/starting-out-with-java-from- control-structures-through-objects-7e-tony-gaddis-46116578 Explore and download more ebooks at ebookbell.com
  • 2.
    Here are somerecommended products that we believe you will be interested in. You can click the link to download. Starting Out With Java From Control Structures Through Objects 7th Edition Tony Gaddis https://ebookbell.com/product/starting-out-with-java-from-control- structures-through-objects-7th-edition-tony-gaddis-49695132 Starting Out With Java From Control Structures Through Objects Plus Myprogramminglab With Pearson Etext Access Card Package 6th Gaddis https://ebookbell.com/product/starting-out-with-java-from-control- structures-through-objects-plus-myprogramminglab-with-pearson-etext- access-card-package-6th-gaddis-22020002 Starting Out With Java From Control Structures Through Objects 5th Edition Tony Gaddis https://ebookbell.com/product/starting-out-with-java-from-control- structures-through-objects-5th-edition-tony-gaddis-4078718 Starting Out With Java From Control Structures Through Objects Testbank 5th Edition Tony Gaddis https://ebookbell.com/product/starting-out-with-java-from-control- structures-through-objects-testbank-5th-edition-tony-gaddis-5106146
  • 3.
    Starting Out WithJava From Control Structures Through Objects Powerpoint Lecture Slides 5th Edition Tony Gaddis https://ebookbell.com/product/starting-out-with-java-from-control- structures-through-objects-powerpoint-lecture-slides-5th-edition-tony- gaddis-5106112 Starting Out With Java From Control Structures Through Data Structures Whats New In Computer Science 4th Edition Gaddis https://ebookbell.com/product/starting-out-with-java-from-control- structures-through-data-structures-whats-new-in-computer-science-4th- edition-gaddis-11164558 Starting Out With Java From Control Structures Through Data Structures 2nd Edition Tony Gaddis https://ebookbell.com/product/starting-out-with-java-from-control- structures-through-data-structures-2nd-edition-tony-gaddis-4671166 Starting Out With Java Early Objects Fifth Edition Gaddis Tony https://ebookbell.com/product/starting-out-with-java-early-objects- fifth-edition-gaddis-tony-21355090 Starting Out With Java 5 Lab Manual Diane Christen https://ebookbell.com/product/starting-out-with-java-5-lab-manual- diane-christen-5399056
  • 7.
    Starting Out WithJava ™ From Control Structures through Objects
  • 8.
    Starting Out WithJava ™ From Control Structures through Objects SEVENTH EDITION Tony Gaddis Haywood Community College 330 Hudson Street, NY NY 10013
  • 9.
    Senior Vice PresidentCourseware Portfolio Management: Marcia J. Horton Director, Portfolio Management: Engineering, Computer Science & Global Editions: Julian Partridge Portfolio Manager: Matt Goldstein Portfolio Management Assistant: Meghan Jacoby Managing Content Producer: Scott Disanno Content Producer: Amanda Brands Rights and Permissions Manager: Ben Ferrini Manufacturing Buyer, Higher Ed, Lake Side Communications, Inc. (LSC): Maura Zaldivar-Garcia Inventory Manager: Ann Lam Product Marketing Manager: Yvonne Vannatta Field Marketing Manager: Demetrius Hall Marketing Assistant: Jon Bryant Cover Designer: Joyce Wells Cover Photo: Shutterstock/Tim UR Printer/Binder: LSC Communications, Inc. Full-Service Project Management: Sasibalan Chidambaram, SPi Global Credits and acknowledgments borrowed from other sources and reproduced, with permission, in this textbook appear on appropriate page within text. Copyright © 2019, 2016, 2013 by Pearson Education, Inc., Hoboken, New Jersey 07030. All rights reserved. Manufactured in the United States of America. This publication is protected by copyright and permissions should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or
  • 10.
    likewise. For informationregarding permissions, request forms and the appropriate contacts within the Pearson Education Global Rights & Permissions department, please visit http://www.pearsoned.com/ permissions/. Many of the designations by manufacturers and seller to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed in initial caps or all caps. Unless otherwise indicated herein, any third-party trademarks that may appear in this work are the property of their ­ respective owners and any references to third-party trademarks, logos or other trade dress are for demonstrative or descriptive purposes only. Such references are not intended to imply any sponsorship, endorsement, authorization, or promotion of Pearson’s products by the owners of such marks, or any relationship between the owner and Pearson Education, Inc. or its affiliates, authors, licensees or distributors. 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 suppliers 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
  • 11.
    connection with theuse or performance of information available from the services. The documents and related graphics contained herein could include technical inaccuracies or typographical errors changes are periodically added to the information herein. Microsoft and/or its respective suppliers 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 Windows , and Microsoft Office are registered trademarks of the Microsoft Corporation in the U.S.A. and other countries. This book is not sponsored or endorsed by or affiliated with the Microsoft Corporation. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners. Library of Congress Cataloging-in-Publication Data Names: Gaddis, Tony, author. Title: Starting out with Java. From control structures through objects / Tony Gaddis, Haywood Community College. Description: Seventh edition. | NY, NY : Pearson Education, Inc., [2019] | Includes index. Identifiers: LCCN 2017060354| ISBN 9780134802213 | ISBN 0134802217 Subjects: LCSH: Java (Computer program language) | Data structures (Computer science) | Object-oriented programming (Computer science) ® ® ®
  • 12.
    Classification: LCC QA76.73.J38G333 2019 | DDC 005.13/3--dc23 LC record available at https://lccn.loc.gov/2017060354 1 18 ISBN 10: 0-13-480221-7 ISBN 13: 978-0-13-480221-3
  • 13.
    Contents in Brief Chapter1 Introduction to Computers and Java 1 Chapter 2 Java Fundamentals 27 Chapter 3 Decision Structures 111 Chapter 4 Loops and Files 189 Chapter 5 Methods 269 Chapter 6 A First Look at Classes 317 Chapter 7 Arrays and the ArrayList Class 403 Chapter 8 A Second Look at Classes and Objects 493 Chapter 9 Text Processing and More about Wrapper Classes 557 Chapter 10 Inheritance 611 Chapter 11 Exceptions and Advanced File I/O 701 Chapter 12 JavaFX: GUI Programming and Basic Controls 759 Chapter 13 JavaFX: Advanced Controls 823 Chapter 14 JavaFX: Graphics, Effects, and Media 909 Chapter 15 Recursion 999 Chapter 16 Databases 1027 Index 1109 Appendices A–M Companion Website Case Studies 1–7 Companion Website                 
  • 14.
  • 15.
    Contents Preface xxiii Chapter 1Introduction to Computers and Java 1 1.1 Introduction 1 1.2 Why Program? 1 1.3 Computer Systems: Hardware and Software 2 Hardware 2 Software 5 1.4 Programming Languages 6 What Is a Program? 6 A History of Java 8 1.5 What Is a Program Made Of? 8 Language Elements 8 Lines and Statements 11 Variables 11 The Compiler and the Java Virtual Machine 12 Java Software Editions 13 Compiling and Running a Java Program 14 1.6 The Programming Process 16 Software Engineering 18 1.7 Object-Oriented Programming 19 Review Questions and Exercises 21                     
  • 16.
    Programming Challenge 25 Chapter2 Java Fundamentals 27 2.1 The Parts of a Java Program 27 2.2 The print and println Methods, and the Java API 33 2.3 Variables and Literals 39 Displaying Multiple Items with the Operator 40 Be Careful with Quotation Marks 41 More about Literals 42 Identifiers 42 Class Names 44 2.4 Primitive Data Types 44 The Integer Data Types 46 Floating-Point Data Types 47 The boolean Data Type 50 The char Data Type 50 Variable Assignment and Initialization 52 Variables Hold Only One Value at a Time 53 2.5 Arithmetic Operators 54 Integer Division 57 Operator Precedence 57 Grouping with Parentheses 59 The Math Class 62 2.6 Combined Assignment Operators 63      +                  
  • 17.
    2.7 Conversion betweenPrimitive Data Types 65 Mixed Integer Operations 67 Other Mixed Mathematical Expressions 68 2.8 Creating Named Constants with final 69 2.9 The String Class 70 Objects Are Created from Classes 71 The String Class 71 Primitive Type Variables and Class Type Variables 71 Creating a String Object 72 2.10 Scope 76 2.11 Comments 78 2.12 Programming Style 83 2.13 Reading Keyboard Input 85 Reading a Character 89 Mixing Calls to nextLine with Calls to Other Scanner Methods 89 2.14 Dialog Boxes 93 Displaying Message Dialogs 93 Displaying Input Dialogs 94 An Example Program 94 Converting String Input to Numbers 96 2.15 Common Errors to Avoid 99 Review Questions and Exercises 100 Programming Challenges 106                       
  • 18.
    Chapter 3 DecisionStructures 111 3.1 The if Statement 111 Using Relational Operators to Form Conditions 113 Putting It All Together 114 Programming Style and the if Statement 117 Be Careful with Semicolons 117 Having Multiple Conditionally Executed Statements 118 Flags 118 Comparing Characters 119 3.2 The if-else Statement 120 3.3 Nested if Statements 122 3.4 The if-else-if Statement 128 3.5 Logical Operators 134 The Precedence of Logical Operators 139 Checking Numeric Ranges with Logical Operators 140 3.6 Comparing String Objects 142 Ignoring Case in String Comparisons 146 3.7 More about Variable Declaration and Scope 147 3.8 The Conditional Operator (Optional) 149 3.9 The switch Statement 150 3.10 Displaying Formatted Output with System.out.printf and String.format 160 Format Specifier Syntax 163                      
  • 19.
    Precision 164 Specifying aMinimum Field Width 164 Flags 167 Formatting String Arguments 170 The String.format Method 172 3.11 Common Errors to Avoid 174 Review Questions and Exercises 175 Programming Challenges 181 Chapter 4 Loops and Files 189 4.1 The Increment and Decrement Operators 189 The Difference between Postfix and Prefix Modes 192 4.2 The while Loop 193 The while Loop Is a Pretest Loop 196 Infinite Loops 196 Don’t Forget the Braces with a Block of Statements 197 Programming Style and the while Loop 198 4.3 Using the while Loop for Input Validation 200 4.4 The do-while Loop 204 4.5 The for Loop 207 The for Loop Is a Pretest Loop 210 Avoid Modifying the Control Variable in the Body of the for Loop 211 Other Forms of the Update Expression 211 Declaring a Variable in the for Loop’s Initialization Expression 211                       
  • 20.
    Creating a UserControlled for Loop 212 Using Multiple Statements in the Initialization and Update Expressions 213 4.6 Running Totals and Sentinel Values 216 Using a Sentinel Value 219 4.7 Nested Loops 221 4.8 The break and continue Statements (Optional) 229 4.9 Deciding Which Loop to Use 229 4.10 Introduction to File Input and Output 230 Using the PrintWriter Class to Write Data to a File 230 Appending Data to a File 236 Specifying the File Location 237 Reading Data from a File 237 Reading Lines from a File with the nextLine Method 238 Adding a throws Clause to the Method Header 241 Checking for a File’s Existence 245 4.11 Generating Random Numbers with the Random Class 249 4.12 Common Errors to Avoid 255 Review Questions and Exercises 256 Programming Challenges 262 Chapter 5 Methods 269 5.1 Introduction to Methods 269 void Methods and Value-Returning Methods 270 Defining a void Method 271                       
  • 21.
    Calling a Method272 Layered Method Calls 276 Using Documentation Comments with Methods 277 5.2 Passing Arguments to a Method 279 Argument and Parameter Data Type Compatibility 281 Parameter Variable Scope 282 Passing Multiple Arguments 282 Arguments Are Passed by Value 284 Passing Object References to a Method 285 Using the @param Tag in Documentation Comments 288 5.3 More about Local Variables 290 Local Variable Lifetime 292 Initializing Local Variables with Parameter Values 292 5.4 Returning a Value from a Method 293 Defining a Value-Returning Method 293 Calling a Value-Returning Method 294 Using the @return Tag in Documentation Comments 296 Returning a boolean Value 300 Returning a Reference to an Object 300 5.5 Problem Solving with Methods 302 Calling Methods That Throw Exceptions 305 5.6 Common Errors to Avoid 305 Review Questions and Exercises 306                       
  • 22.
    Programming Challenges 311 Chapter6 A First Look at Classes 317 6.1 Objects and Classes 317 Classes: Where Objects Come From 318 Classes in the Java API 319 Primitive Variables vs. Objects 321 6.2 Writing a Simple Class, Step by Step 324 Accessor and Mutator Methods 338 The Importance of Data Hiding 338 Avoiding Stale Data 339 Showing Access Specification in UML Diagrams 339 Data Type and Parameter Notation in UML Diagrams 339 Layout of Class Members 340 6.3 Instance Fields and Methods 341 6.4 Constructors 346 Showing Constructors in a UML Diagram 348 Uninitialized Local Reference Variables 348 The Default Constructor 348 Writing Your Own No-Arg Constructor 349 The String Class Constructor 350 6.5 Passing Objects as Arguments 358 6.6 Overloading Methods and Constructors 370 The BankAccount Class 372                       
  • 23.
    Overloaded Methods MakeClasses More Useful 378 6.7 Scope of Instance Fields 378 Shadowing 379 6.8 Packages and import Statements 380 Explicit and Wildcard import Statements 380 The java.lang Package 381 Other API Packages 381 6.9 Focus on Object-Oriented Design: Finding the Classes and Their Responsibilities 382 Finding the Classes 382 Identifying a Class’s Responsibilities 385 This Is Only the Beginning 388 6.10 Common Errors to Avoid 388 Review Questions and Exercises 389 Programming Challenges 394 Chapter 7 Arrays and the ArrayList Class 403 7.1 Introduction to Arrays 403 Accessing Array Elements 405 Inputting and Outputting Array Contents 406 Java Performs Bounds Checking 409 Watch Out for Off-by-One Errors 410 Array Initialization 411 Alternate Array Declaration Notation 412                      
  • 24.
    7.2 Processing ArrayElements 413 Array Length 415 The Enhanced for Loop 416 Letting the User Specify an Array’s Size 417 Reassigning Array Reference Variables 419 Copying Arrays 420 7.3 Passing Arrays as Arguments to Methods 422 7.4 Some Useful Array Algorithms and Operations 426 Comparing Arrays 426 Summing the Values in a Numeric Array 427 Getting the Average of the Values in a Numeric Array 428 Finding the Highest and Lowest Values in a Numeric Array 428 The SalesData Class 429 Partially Filled Arrays 437 Working with Arrays and Files 438 7.5 Returning Arrays from Methods 439 7.6 String Arrays 441 Calling String Methods from an Array Element 443 7.7 Arrays of Objects 444 7.8 The Sequential Search Algorithm 447 7.9 Two-Dimensional Arrays 450 Initializing a Two-Dimensional Array 454 The length Field in a Two-Dimensional Array 455                       
  • 25.
    Displaying All theElements of a Two-Dimensional Array 457 Summing All the Elements of a Two-Dimensional Array 457 Summing the Rows of a Two-Dimensional Array 458 Summing the Columns of a Two-Dimensional Array 458 Passing Two-Dimensional Arrays to Methods 459 Ragged Arrays 461 7.10 Arrays with Three or More Dimensions 462 7.11 The Selection Sort and the Binary Search Algorithms 463 The Selection Sort Algorithm 463 The Binary Search Algorithm 466 7.12 Command-Line Arguments and Variable-Length Argument Lists 468 Command-Line Arguments 469 Variable-Length Argument Lists 470 7.13 The ArrayList Class 472 Creating and Using an ArrayList Object 473 Using the Enhanced for Loop with an ArrayList 474 The ArrayList Class’s toString method 475 Removing an Item from an ArrayList 476 Inserting an Item 477 Replacing an Item 478 Capacity 479 Storing Your Own Objects in an ArrayList 479                      
  • 26.
    Using the DiamondOperator for Type Inference 480 7.14 Common Errors to Avoid 481 Review Questions and Exercises 481 Programming Challenges 486 Chapter 8 A Second Look at Classes and Objects 493 8.1 Static Class Members 493 A Quick Review of Instance Fields and Instance Methods 493 Static Members 494 Static Fields 494 Static Methods 497 8.2 Passing Objects as Arguments to Methods 500 8.3 Returning Objects from Methods 503 8.4 The toString Method 505 8.5 Writing an equals Method 509 8.6 Methods That Copy Objects 512 Copy Constructors 514 8.7 Aggregation 515 Aggregation in UML Diagrams 523 Security Issues with Aggregate Classes 523 Avoid Using null References 525 8.8 The this Reference Variable 528 Using this to Overcome Shadowing 529                      
  • 27.
    Using this toCall an Overloaded Constructor from Another Constructor 530 8.9 Enumerated Types 531 Enumerated Types Are Specialized Classes 532 Switching On an Enumerated Type 538 8.10 Garbage Collection 540 The finalize Method 542 8.11 Focus on Object-Oriented Design: Class Collaboration 542 Determining Class Collaborations with CRC Cards 545 8.12 Common Errors to Avoid 546 Review Questions and Exercises 547 Programming Challenges 551 Chapter 9 Text Processing and More about Wrapper Classes 557 9.1 Introduction to Wrapper Classes 557 9.2 Character Testing and Conversion with the Character Class 558 Character Case Conversion 563 9.3 More String Methods 566 Searching for Substrings 566 Extracting Substrings 572 Methods That Return a Modified String 576 The Static valueOf Methods 577 9.4 The StringBuilder Class 579 The StringBuilder Constructors 580 Other StringBuilder Methods 581                       
  • 28.
    The toString Method584 9.5 Tokenizing Strings 589 9.6 Wrapper Classes for the Numeric Data Types 594 The Static toString Methods 594 The toBinaryString , toHexString , and toOctalString Methods 594 The MIN_VALUE and MAX_VALUE Constants 595 Autoboxing and Unboxing 595 9.7 Focus on Problem Solving: The TestScoreReader Class 597 9.8 Common Errors to Avoid 601 Review Questions and Exercises 601 Programming Challenges 605 Chapter 10 Inheritance 611 10.1 What Is Inheritance? 611 Generalization and Specialization 611 Inheritance and the “Is a” Relationship 612 Inheritance in UML Diagrams 620 The Superclass’s Constructor 621 Inheritance Does Not Work in Reverse 623 10.2 Calling the Superclass Constructor 624 When the Superclass Has No Default or No-Arg Constructors 630 Summary of Constructor Issues in Inheritance 631 10.3 Overriding Superclass Methods 632                      
  • 29.
    Overloading versus Overriding637 Preventing a Method from Being Overridden 640 10.4 Protected Members 641 Package Access 646 10.5 Chains of Inheritance 647 Class Hierarchies 653 10.6 The Object Class 653 10.7 Polymorphism 655 Polymorphism and Dynamic Binding 656 The “Is-a” Relationship Does Not Work in Reverse 658 The instanceof Operator 659 10.8 Abstract Classes and Abstract Methods 660 Abstract Classes in UML 666 10.9 Interfaces 667 An Interface is a Contract 669 Fields in Interfaces 673 Implementing Multiple Interfaces 673 Interfaces in UML 673 Default Methods 674 Polymorphism and Interfaces 676 10.10 Anonymous Inner Classes 681 10.11 Functional Interfaces and Lambda Expressions 684 10.12 Common Errors to Avoid 689                       
  • 30.
    Review Questions andExercises 690 Programming Challenges 696 Chapter 11 Exceptions and Advanced File I/O 701 11.1 Handling Exceptions 701 Exception Classes 702 Handling an Exception 703 Retrieving the Default Error Message 707 Polymorphic References to Exceptions 710 Using Multiple catch Clauses to Handle Multiple Exceptions 710 The finally Clause 718 The Stack Trace 720 Handling Multiple Exceptions with One catch Clause 721 When an Exception Is Not Caught 723 Checked and Unchecked Exceptions 724 11.2 Throwing Exceptions 725 Creating Your Own Exception Classes 728 Using the @exception Tag in Documentation Comments 731 11.3 Advanced Topics: Binary Files, Random Access Files, and Object Serialization 732 Binary Files 732 Random Access Files 739 Object Serialization 744 Serializing Aggregate Objects 748                      
  • 31.
    11.4 Common Errorsto Avoid 749 Review Questions and Exercises 749 Programming Challenges 755 Chapter 12 JavaFX: GUI Programming and Basic Controls 759 12.1 Graphical User Interfaces 759 Event-Driven GUI Programs 761 12.2 Introduction to JavaFX 762 Controls 762 Stages and Scenes 763 The Application Class 763 12.3 Creating Scenes 765 Creating Controls 766 Creating Layout Containers 766 Creating a Scene Object 767 Adding the Scene Object to the Stage 768 Setting the Size of the Scene 770 Aligning Controls in an HBox Layout Container 770 12.4 Displaying Images 772 Loading Images from an Internet Location 775 Setting the Size of an Image 775 Preserving the Image’s Aspect Ratio 775 Changing an ImageView’s Image 776 12.5 More about the HBox, VBox , and GridPane Layout Containers 776                       
  • 32.
    The HBox LayoutContainer 777 The VBox Layout Container 782 The GridPane Layout Container 784 Using Multiple Layout Containers in the Same Screen 791 12.6 Button Controls and Events 792 Handling Events 794 Writing Event Handlers 794 Registering an Event Handler 795 12.7 Reading Input with TextField Controls 799 12.8 Using Anonymous Inner Classes and Lambda Expressions to Handle Events 803 Using Anonymous Inner Classes to Create Event Handlers 803 Using Lambda Expressions to Create Event Handlers 806 12.9 The BorderPane Layout Container 808 12.10 The ObservableList Interface 812 12.11 Common Errors to Avoid 814 Review Questions and Exercises 814 Programming Challenges 818 Chapter 13 JavaFX: Advanced Controls 823 13.1 Styling JavaFX Applications with CSS 823 Type Selector Names 824 Style Properties 825 Applying a Stylesheet to a JavaFX Application 826                      
  • 33.
    Applying Styles tothe Root Node 830 Specifying Multiple Selectors in the Same Style Definition 832 Working with Colors 832 Creating a Custom Style Class Name 834 ID Selectors 836 Inline Style Rules 837 13.2 RadioButton Controls 838 Determining in Code Whether a RadioButton Is Selected 839 Selecting a RadioButton in Code 839 Responding to RadioButton Clicks 844 13.3 CheckBox Controls 848 Determining in Code Whether a CheckBox Is Selected 848 Selecting a CheckBox in Code 849 Responding to CheckBox Clicks 853 13.4 ListView Controls 853 Retrieving the Selected Item 855 Retrieving the Index of the Selected Item 856 Responding to Item Selection with an Event Handler 859 Adding Items versus Setting Items 860 Initializing a ListView with an Array or an ArrayList 861 Selection Modes 862 Retrieving Multiple Selected Items 863                      
  • 34.
    Working With theElements of an ObservableList 866 Converting an ObservableList to an Array 867 Using Code to Select an Item in a ListView 868 ListView Orientation 868 Creating ListViews of Objects Other Than String 869 13.5 ComboBox Controls 874 Retrieving the Selected Item 875 Responding to ComboBox Item Selection with an Event Handler 877 Editable ComboBoxes 879 13.6 Slider Controls 880 13.7 TextArea Controls 885 13.8 Menus 887 Assigning Mnemonics to Menu Items 895 13.9 The FileChooser Class 897 Displaying a FileChooser Dialog Box 898 13.10 Using Console Output to Debug a GUI Application 898 13.11 Common Errors to Avoid 902 Review Questions 902 Programming Challenges 906 Chapter 14 JavaFX: Graphics, Effects, and Media 909 14.1 Drawing Shapes 909 The Screen Coordinate System 909 The Shape Class and Its Subclasses 910                       
  • 35.
    The Line Class911 Changing the Stroke Color 914 The Circle Class 914 The Rectangle Class 918 The Ellipse Class 921 The Arc Class 924 The Polygon Class 928 The Polyline Class 931 The Text Class 933 Rotating Nodes 936 Scaling Nodes 938 14.2 Animation 940 The TranslateTransition Class 941 The RotateTransition Class 944 The ScaleTransition Class 949 The StrokeTransition Class 952 The FillTransition Class 953 The FadeTransition Class 954 Controlling the Animation 956 Specifying an Interpolator 956 14.3 Effects 958 The DropShadow Class 958                      
  • 36.
    The InnerShadow Class961 The ColorAdjust Class 962 The BoxBlur , GaussianBlur , and MotionBlur Classes 962 The SepiaTone Class 965 The Glow Class 966 The Reflection Class 967 Combining Effects 967 14.4 Playing Sound Files 969 Registering an EndOfMedia Event Handler 971 14.5 Playing Videos 974 14.6 Handling Key Events 979 Using an Anonymous Inner Class to Register a Key Event Handler to the Scene 980 Using a Lambda Expression to Register a Key Event Handler to the Scene 981 14.7 Handling Mouse Events 986 14.8 Common Errors to Avoid 992 Review Questions 992 Programming Challenges 995 Chapter 15 Recursion 999 15.1 Introduction to Recursion 999 15.2 Solving Problems with Recursion 1002 Direct and Indirect Recursion 1006 15.3 Examples of Recursive Methods 1007                      
  • 37.
    Summing a Rangeof Array Elements with Recursion 1007 Drawing Concentric Circles 1008 The Fibonacci Series 1011 Finding the Greatest Common Divisor 1012 15.4 A Recursive Binary Search Method 1014 15.5 The Towers of Hanoi 1017 15.6 Common Errors to Avoid 1021 Review Questions and Exercises 1022 Programming Challenges 1025 Chapter 16 Databases 1027 16.1 Introduction to Database Management Systems 1027 JDBC 1028 SQL 1029 Using a DBMS 1029 Java DB and Apache Derby 1030 Creating the CoffeeDB Database 1030 Connecting to the CoffeeDB Database 1030 Connecting to a Password-Protected Database 1032 16.2 Tables, Rows, and Columns 1033 Column Data Types 1035 Primary Keys 1035 16.3 Introduction to the SQL SELECT Statement 1036 Passing an SQL Statement to the DBMS 1038                       
  • 38.
    Specifying Search Criteriawith the WHERE Clause 1048 Sorting the Results of a SELECT Query 1054 Mathematical Functions 1055 16.4 Inserting Rows 1058 Inserting Rows with JDBC 1060 16.5 Updating and Deleting Existing Rows 1062 Updating Rows with JDBC 1063 Deleting Rows with the DELETE Statement 1067 Deleting Rows with JDBC 1067 16.6 Creating and Deleting Tables 1071 Removing a Table with the DROP TABLE Statement 1074 16.7 Creating a New Database with JDBC 1074 16.8 Scrollable Result Sets 1076 16.9 Result Set Metadata 1077 16.10 Relational Data 1084 Joining Data from Multiple Tables 1086 An Order Entry System 1087 16.11 Advanced Topics 1100 Transactions 1100 Stored Procedures 1101 16.12 Common Errors to Avoid 1102 Review Questions and Exercises 1102 Programming Challenges 1107                       
  • 39.
    Index 1109 The followingappendices, online chapters, and online case studies are available on the book’s online resource page at www.pearson.com/cs-resources. Online Appendices: Appendix A: The ASCII/Unicode Characters Appendix B: Operator Precedence and Associativity Appendix C: Java Key Words Appendix D: Installing the JDK and Using the JDK Documentation Appendix E: Using the javadoc Utility Appendix F: More about the Math Class Appendix G: Packages Appendix H: Working with Records and Random - Access Files Appendix I: Configuring Java DB and Installing Apache Derby Appendix J: The QuickSort Algorithm Appendix K: Named Colors Appendix L: Answers to Checkpoints Appendix M: Answers to Odd-Numbered Review Questions Online Chapters: Chapter 17: A First look at GUI Applications Chapter 18: Advanced GUI Applications Chapter 19: Applets and More Chapter 20: Creating GUI Applications with JavaFX and Scene Builder                  
  • 40.
    Online Case Studies: CaseStudy 1: Calculating Sales Commission Case Study 2: The Amortization Class Case Study 3: The PinTester Class Case Study 4: Parallel Arrays Case Study 5: The FeetInches Class Case Study 6: The SerialNumber Class Case Study 7: A Simple Text Editor Application       
  • 41.
    Location of videonotesin the text Chapter 1 Compiling and Running a Java Program, p. 14 Using an IDE, p. 14 Your First Java Program, p. 25 Chapter 2 Displaying Console Output, p. 33 Declaring Variables, p. 39 Simple Math Expressions, p. 55 The Miles-per-Gallon Problem, p. 107 Chapter 3 The if Statement, p. 111 The if-else Statement, p. 120 The if-else-if Statement, p. 129 The Time Calculator Problem, p. 182 Chapter 4 The while Loop, p. 193 The Pennies for Pay Problem, p. 263    
  • 42.
    Chapter 5 Passing Arguments toa Method, p. 279 Returning a Value from a Method, p. 293 The Retail Price Calculator Problem, p. 311 Chapter 6 Writing Classes and Creating Objects, p. 325 Initializing an Object with a Constructor, p. 346 The Personal Information Class Problem, p. 395 Chapter 7 Accessing Array Elements in a Loop, p. 407 Passing an Array to a Method, p. 422 The Charge Account Validation Problem, p. 487 Chapter 8 Returning Objects from Methods, p. 503 Aggregation, p. 515 The BankAccount , Class Copy Constructor Problem, p. 552    
  • 43.
    Chapter 9 The Sentence CapitalizerProblem, p. 605 Chapter 10 Inheritance, p. 611 Polymorphism, p. 655 The Employee and Productionworker Classes Problem, p. 696 Chapter 11 Handling Exceptions, p. 701 The Exception Project Problem, p. 757 Chapter 12 Introduction to JavaFX, p. 762 Creating Scenes, p. 765 Displaying Images, p. 772 The HBox Layout Container, p. 777 The VBox Layout Container, p. 782 The GridPane Layout Container, p. 784 Button Controls and Events, p. 792    
  • 44.
    The TextField Control,p. 799 Using Anonymous Inner Classes as Event Handlers, p. 803 Using Lambda Expressions as Event Handlers, p. 806 The Latin Translator Problem, p. 818 Chapter 13 JavaFX and CSS, p. 823 RadioButton Controls, p. 838 CheckBox Controls, p. 848 ListView Controls, p. 853 ComboBox Controls, p. 874 Slider Controls, p. 880 The Dorm and Meal Plan Calculator Problem, p. 906 Chapter 14 Drawing Shapes with JavaFX, p. 909 JavaFX Animation, p. 940 JavaFX Effects, p. 958  
  • 45.
    Playing Sound Fileswith JavaFX, p. 970 Playing Videos with JavaFX, p. 974 Handling Key Events in JavaFX, p. 979 Handling Mouse Events in JavaFX, p. 986 The Coin Toss Problem, p. 996 Chapter 15 Reducing a Problem with Recursion, p. 1003 The Recursive Power Problem, p. 1026 Chapter 16 The Customer Inserter Problem, p. 1107  
  • 46.
    Preface Welcome to StartingOut with Java: From Control Structures through Objects, Seventh Edition. This book is intended for a one-semester or a two- quarter CS1 course. Although it is written for students with no prior programming background, even experienced students will benefit from its depth of detail. Control Structures First, Then Objects This text first introduces the student to the fundamentals of data types, input and output, control structures, methods, and objects created from standard library classes. Next, the student learns to use arrays of primitive types and reference types. After this, the student progresses through more advanced topics, such as inheritance, polymorphism, the creation and management of packages, GUI applications, recursion, and database programming. From early in the book, applications are documented with javadoc comments. As the student progresses through the text, new javadoc tags are covered and demonstrated. As with all the books in the Starting Out With … series, the hallmark of this text is its clear, friendly, and easy-to-understand writing. In addition, it is rich in example programs that are concise and practical.
  • 47.
    Changes in theSeventh Edition This book’s pedagogy, organization, and clear writing style remain the same as in the previous edition. The most significant change in this edition is the switch from Swing to JavaFX in the chapters that focus on GUI development. Although Swing is not officially deprecated, Oracle has announced that JavaFX has replaced Swing as the standard GUI library for Java. http://www.oracle.com/technetwork/java/javafx/overview/faq-1446554.html#6 In this edition, we have added the following new chapters: CHAPTER 12 JAVAFX: GUI PROGRAMMING AND BASIC CONTROLS This chapter presents the basics of developing graphical user interface (GUI) applications with JavaFX. Fundamental controls, layout containers, and the basic concepts of event-driven programming are covered. CHAPTER 13 JAVAFX: ADVANCED CONTROLS This chapter discusses CSS styling and advanced user interface controls. CHAPTER 14 JAVAFX: GRAPHICS, EFFECTS, AND MEDIA This chapter discusses 2D shapes, animation, visual effects, playing audio and video, and responding to mouse and keyboard events. The Swing and Applet material that appeared in the previous edition is still available on the book’s companion Web site, as the following online chapters: The previous Chapter 12 A First Look At GUI Applications is now available online as Chapter 17 . The previous Chapter 13 Advanced GUI Applications is now available online as ­ Chapter 18 . 1 1       
  • 48.
    The previous Chapter14 Applets and More is now available online as Chapter 19 . Note: Chapter 15 from the previous edition has also been moved to the book’s companion Web site as Chapter 20 Creating JavaFX Applications with Scene Builder. Although Oracle no longer officially supports Scene Builder, it is still available as an open source tool at http://http://gluonhq.com/labs/scene-builder/ In addition to the new JavaFX chapters, the Database chapter, which is now Chapter 15 , has been updated to use JavaFX instead of Swing for its GUI applications. We have also added several new, motivational programming problems throughout the book. Organization of the Text The text teaches Java step-by-step. Each chapter covers a major set of topics and builds knowledge as students progress through the book. Although the chapters can be easily taught in their existing sequence, there is some flexibility. Figure P-1 shows chapter dependencies. Each box represents a chapter or a group of chapters. An arrow points from a chapter to the chapter that must be previously covered.      
  • 49.
    Figure P-1 Chapterdependencies
  • 51.
    Brief Overview ofEach Chapter
  • 52.
    Chapter 1 :Introduction to Computers and Java. This chapter provides an introduction to the field of computer science and covers the fundamentals of hardware, software, and programming languages. The elements of a program, such as key words, variables, operators, and punctuation, are discussed by examining a simple program. An overview of entering source code, compiling, and executing a program is presented. A brief history of Java is also given. Chapter 2 : Java Fundamentals. This chapter gets students started in Java by introducing data types, identifiers, variable declarations, constants, comments, program output, and simple arithmetic operations. The conventions of programming style are also introduced. Students learn to read console input with the Scanner class and with dialog boxes using JOptionPane . Chapter 3 : Decision Structures. In this chapter students explore relational operators and relational expressions and are shown how to control the flow of a program with the if , if-else , and if-else-if statements. Nested if statements, logical operators, the conditional operator, and the switch statement are also covered. The chapter discusses how to compare String objects with the equals , compareTo , equalsIgnoreCase , and compareToIgnoreCase methods. Formatting numeric output with the System.out.printf method and the String.format method is discussed.   
  • 53.
    Chapter 4 :Loops and Files. This chapter covers Java’s repetition control structures. The while loop , do-while loop , and for loop are taught, along with common uses for these devices. Counters, accumulators, running totals, sentinels, and other application-related topics are discussed. Simple file operations for reading and writing text files are included. Chapter 5 : Methods. In this chapter students learn how to write void methods, value-returning methods, and methods that do and do not accept arguments. The concept of functional decomposition is discussed. Chapter 6 : A First Look at Classes. This chapter introduces students to designing classes for the purpose of instantiating objects. Students learn about class fields and methods, and UML diagrams are introduced as a design tool. Then constructors and overloading are discussed. A BankAccount class is presented as a case study, and a section on object-oriented design is included. This section leads the students through the process of identifying classes and their responsibilities within a problem domain. There is also a section that briefly explains packages and the import statement. Chapter 7 : Arrays and the ArrayList Class. In this chapter students learn to create and work with single and multi- dimensional arrays. Numerous array-processing techniques are demonstrated, such as summing the elements in an array, finding the highest and lowest values, and sequentially searching an array. Other topics, including ragged arrays and variable-length arguments (varargs), are also discussed. The ArrayList class is introduced, and Java’s generic types are briefly discussed and demonstrated.    
  • 54.
    Chapter 8 :A Second Look at Classes and Objects. This chapter shows students how to write classes with added capabilities. Static methods and fields, interaction between objects, passing objects as arguments, and returning objects from methods are discussed. Aggregation and the “has a” relationship is covered, as well as enumerated types. A section on object-oriented design shows how to use CRC cards to determine the collaborations among classes. Chapter 9 : Text Processing and More about Wrapper Classes. This chapter discusses the numeric and Character wrapper classes. Methods for converting numbers to strings, testing the case of characters, and converting the case of characters are covered. Autoboxing and unboxing are also discussed. More String class methods are covered, including using the split method to tokenize strings. The chapter also covers the StringBuilder class. Chapter 10 : Inheritance. The study of classes continues in this chapter with the subjects of inheritance and polymorphism. The topics covered include superclasses, subclasses, how constructors work in inheritance, method overriding, polymorphism and dynamic binding, protected and package access, class hierarchies, abstract classes, abstract methods, anonymous inner classes, interfaces, and lambda expressions.   
  • 55.
    Another Random Documenton Scribd Without Any Related Topics
  • 56.
    behaves in thesame manner. Wheat flour, made into a paste with water, and left for four or five days in a warm situation, becomes a true lactic acid ferment; but if left a day or two longer, it changes its character, and then acts like common yeast, occasioning the ordinary panary or vinous fermentation. Moist animal membranes, in a slightly decaying condition, often act energetically in developing lactic acid. The rennet employed in the manufacture of cheese furnishes a well-known example of this class of substances. In preparing lactic acid from milk, the acid formed, after a time, coagulates and renders insoluble the casein, and the production of the acid ceases. By carefully neutralising the free acid by carbonate of sodium, the casein becomes soluble, and resuming its activity, changes a fresh quantity of sugar into lactic acid, which may be also neutralised, and by a sufficient number of repetitions of this process all the sugar of milk present may, in time, be acidified. This is the rationale of the common process by which lactic acid is obtained. Cane-sugar (probably by previously becoming grape-sugar) and the sugar of milk both yield lactic acid; the latter, however, most readily, the grape-sugar having a strong tendency towards the alcoholic fermentation. If the lactic fermentation be allowed to proceed too far, the second stage of the process of transmutation commences, hydrogen gas and carbonic acid gas are evolved, and the butyric fermentation, by which oily acids are formed, is established. Pasteur ascribes the lactic fermentation to the agency of a specific kind of ferment, which occurs in the form of a greyish layer deposited upon the surface of the sediment formed during the fermentation of the sugar, casein, and chalk (see Lactic acid, b), in the manufacture of lactic acid. If to a mixture of yeast, or any nitrogenous substance, and water, sugar, and then chalk, be added, and finally a very small quantity of this greyish substance, taken from a portion of a liquid undergoing active lactic fermentation, lactic acid fermentation is almost immediately set up, the chalk disappears owing to the formation of calcic lactate, and the greyish substance is copiously
  • 57.
    deposited. When placedunder the microscope this ferment is seen to be composed of “little globules, or very short articulations, either isolated or in threads, constituting irregular flocculent particles, much smaller than those of beer yeast, and exhibiting a rapid gyratory motion.” If these little particles be washed thoroughly in pure water, and then placed in a solution of sugar, lactic acidification immediately commences in the saccharine liquid, and goes on steadily until stopped by the excess of free acid. LAC′TIDE. See Lactic acid. LAC′TIN. See Sugar of Milk. LAC′TOMETER. Syn. Galactometer. An instrument for ascertaining the quality of milk. Milk may be roughly tested by placing it in a long graduated tube sold for the purpose, and allowing it to remain until all the cream has separated and measured, then decanting off the clear whey, and taking its specific gravity; the result of the two operations, when compared with the known quantity of cream and the density of the whey of an average sample of milk, gives the value of the sample tested. See Milk. A little instrument called a ‘milk-tester’ is sold in London at a low price. It is essentially a hydrometer which sinks to a given mark on the stem in pure water, and floats at another mark at the opposite end of the scale in pure milk. The intermediate space indicates the quantity of water (if any) employed to adulterate the article. As the sp. gr. of pure milk varies, the indications of the ‘tester’ cannot be depended on. LAC′TOSE. See Sugar of Milk. LAC′TUCA. (B. P.) Syn. Lettuce. The leaves and flowering tops of the wild indigenous plant Lactuca virosa. They are sedative, narcotic, and powerfully diuretic; also mildly laxative and diaphoretic. Given in dropsy and visceral obstructions. See Lettuce, Extract of.
  • 58.
    LACTUCA′′RIUM. Syn. Lettuceopium. Thridace; Lactucarium (Ph. E. & D.). The inspissated milky juice of the Lactuca sativa (common garden lettuce), or the Lactuca virosa (strong-scented wild lettuce), obtained, by incision, from the flowering stems, and dried in the air. The latter species yields by far the greatest quantity. M. Arnaud, of Nancy, adopts the following method of procuring this substance, which appears to be the most productive and simple of any yet published:—Before the development of the lateral branches, the stems of twelve plants are cut, one after another, a little below the commencement of these branches; returning to the first one, a milky exudation is found on the cut portion, and on that which remains fixed in the earth; this milky exudation is adroitly collected with the end of the finger (or with a bone knife), which is afterwards scraped on the edge of a small glass; the same operation is performed on twelve other heads, and so on; on the third day it is repeated on every portion of the plant remaining in the ground, a thin slice being first cut off the top; this is done every day until the root is reached. As soon as the lactucarium is collected it coagulates; the harvest of each day is divided into small pieces, which are placed on plates, very near each other, but without touching, and allowed to dry for two days, after which they are set aside in a bottle. In this way 15 or 20 times the ordinary product is obtained. Prop., &c. Lactucarium is anodyne, hypnotic, antispasmodic, and sedative, allaying pain and diminishing the force of the circulation. It has been recommended in cases in which opium is inadmissible, and has been administered with advantage in chronic rheumatism, colic, diarrhœa, asthma, and troublesome cough of phthisis, the irritability and watchfulness in febrile disorders, &c.—Dose, 2 to 5 gr.; made into pills, lozenges, or tincture. LACTU′CIN. Syn. Lactucinum, L. This is the active principle of lactucarium, and is found in the juice of several species of lettuce. Prep. Exhaust lactucarium with hot rectified spirit, agitate the tincture with a little animal charcoal, filter, add a little milk of lime,
  • 59.
    and evaporate todryness; digest the residuum in hot rectified spirit; filter, and evaporate by a gentle heat, so that crystals may form. Prop., &c. A nearly colourless, odourless, fusible, neutral, bitter substance; sparingly soluble in cold water and in ether, but freely soluble in alcohol. It possesses feeble basic properties. Good lactucarium contains fully 20% of this substance. LAD′ANUM. See Labdanum. LAENNEC’S CONTRA-STIMULANT. See Draught. LAKE. Syn. Lacca, L. Animal or vegetable colouring matter, precipitated in combination with oxide of tin or alumina; usually the latter. The term was formerly restricted to red preparations of this kind, but is now indiscriminately applied to all compounds of alumina and colouring matter. The term ‘LAKE,’ when unqualified by an adjective, is, however, understood to apply exclusively to that prepared from cochineal. Prep. Lakes are made—1. By adding a solution of alum, either alone or partly saturated with carbonate of potassa, to a filtered infusion or decoction of the colouring substance, and after agitation precipitating the mixture with a solution of carbonate of potash.—2. By precipitating a decoction or infusion of the colouring substance made with a weak alkaline lye, by adding a solution of alum.—3. By agitating recently precipitated alumina with a solution of the colouring matter, prepared as before, until the liquid is nearly decoloured, or the alumina acquires a sufficiently dark tint. The first method is usually employed for acidulous solutions of colouring matter, or for those whose tint is injured by alkalies; the second, for those that are brightened, or at least uninjured, by alkalies; the third, for those colouring matters that have a great affinity for gelatinous alumina, and readily combine with it by mere agitation. By attention to these general rules, lakes may be prepared from almost all animal and vegetable colouring substances that yield their colour to water, many of which will be found to possess great beauty
  • 60.
    and permanence. Theprecise process adapted to each particular substance may be easily ascertained by taking a few drops of its infusion or decoction, and observing the effects of alkalies and acids on the colour. The quantity of alum or of alumina employed should be nearly sufficient to decolour the dye liquor; and the quantity of carbonate of potassa should be so proportioned to the alum as to exactly precipitate the alumina without leaving free or carbonated alkali in the liquid. The first portion of the precipitate has the deepest colour, and the shade gradually becomes paler as the operation proceeds. A beautiful ‘tone’ of violet, red, and even purple, may be communicated to the colouring matter of cochineal by the addition of perchloride of tin; the addition of arseniate of potassa (neutral arsenical salt) in like manner gives shades which may be sought for in vain with alum or alumina. After the lake is precipitated, it must be carefully collected, washed with cold distilled water, or the purest rain water, until it ceases to give out colour, and then carefully dried in the shade. In this state it forms a soft velvety powder. That of the shops is generally made up into conical or pyramidal drops (drop lake), which is done by dropping the moist lake through a small funnel on a clean board or slab, and drying it by a gentle heat as before. A very little clear gum water is commonly added to the paste to give the drops consistence when dry. Lake, Blue. Syn. Lacca cœrulea, L. Prepared from some of the blue-coloured flowers; fugitive. The name is also applied to lump archil (lacca cœrulea), to moist alumina coloured with indigo, and to mixed solutions of pearlash and prussiate of potash, precipitated with another solution of sulphate of iron and alum. These are permanent and beautiful, but are seldom used, in consequence of indigo and Prussian blue supplying all that is wanted in this class of colours. Lake, Brazil-wood. Syn. Drop lake; Lacca in globulis, L. Prep. 1. Take of ground Brazil-wood, 1 lb.; water, 4 galls.; digest for 24 hours, then boil for 30 or 40 minutes, and add of alum, 11⁄2 lb., dissolved in a little water; mix, decant, strain, and add of solution of
  • 61.
    tin, 1⁄2 lb.;again mix well and filter; to the clear liquid add, cautiously, a solution of salt of tartar or carbonate of soda, as long as a deep-coloured precipitate forms, carefully avoiding excess; collect, wash, dry, &c., as directed above. Obs. The product is deep red. By collecting the precipitate in separate portions, lakes varying in richness and depth of colour may be obtained. The first portion of the precipitated lake has the brightest colour. An excess of alkali turns it on the violet, and the addition of cream of tartar, on the brownish red. The tint turns more on the violet red when the solution of tin is omitted. Some persons use less, others more, alum. 2. Add washed and recently precipitated alumina to a strong and filtered decoction of Brazil wood. Inferior to the last. Lake, Carminated. Syn. Cochineal lake, Florence l., Florentine l., Paris l., Vienna l.; Lacca Florentina, L. Prep. 1. The residuum of the cochineal left in making carmine is boiled with repeated portions of water, until it is exhausted of colour; the resulting liquor is mixed with that decanted off the carmine, and at once filtered; some recently precipitated alumina is then added, and the whole gently heated, and well agitated for a short time; as soon as the alumina has absorbed sufficient colour, the mixture is allowed to settle, after which the clear portion is decanted, the lake collected on a filter, washed, and dried, as before. The decanted liquor, if still coloured, is now treated with fresh alumina until exhausted, and thus a lake of a second quality is obtained. Very fine. 2. To the coloured liquor obtained from the carmine and cochineal as above, a solution of alum is added, the filtered liquor precipitated with a solution of carbonate of potassa, and the alum or alumina; this brightens the lake collected and treated as before. Scarcely so good as the last. Obs. Some makers mix a little solution of tin with the coloured liquor before adding colour. The above lake is a good glazing colour
  • 62.
    with oil, buthas little body. It may be made directly from a decoction of cochineal. (See below.) Lake, Cochineal. Prep. 1. Cochineal (in coarse powder), 1 oz.; water and rectified spirit, of each 21⁄2 oz.; digest for a week, filter, and precipitate the tincture with a few drops of solution of tin, added every two hours, until the whole of the colouring matter is thrown down; lastly, wash the precipitate in distilled water, and dry it. Very fine. 2. Digest powdered cochineal in ammonia water for a week, dilute the solution with a little water, and add the liquid to a solution of alum, as long as a precipitate falls, which is the lake. Equal to the last. 3. Coarsely powdered cochineal, 1 lb.; water, 2 galls.; boil 1 hour, decant, strain, add a solution of salt of tartar, 1 lb., and precipitate with a solution of alum. By adding the alum first, and precipitating the lake with the alkali, the colour will be slightly varied. All the above are sold as CARMINATED or Florence lake, to which they are often superior. Lake, Green. Made by mixing blue and yellow lake together. Seldom kept in the shops, being generally prepared extemporaneously by the artist on his palette. Lake, Lac. Prep. Boil fresh stick-lac in a solution of carbonate of soda, filter the solution, precipitate with a solution of alum, and proceed as before. Lake, Lichen. See Orcein. Lake, Madder. Syn. Lacca rubiæ, L. columbina, L. Prep. 1. (Sir H. C. Inglefield.) Take of Dutch grappe or crop madder, 2 oz.; tie it in a cloth, beat it well in a pint of water in a stone mortar, and repeat the process with fresh water (about 5 pints) until it ceases to yield colour; next boil the mixed liquor in an earthen vessel, pour it into a large basin, and add of alum 1 oz., previously dissolved in boiling
  • 63.
    water, 1 pint;stir well, and while stirring, pour in gradually of a strong solution of carbonate of potassa (‘oil of tartar’), 11⁄2 oz.; let the whole stand until cold, then pour off the supernatant yellow liquor, drain, agitate the residue with boiling water, 1 quart (in separate portions), decant, drain, and dry. Product, 1⁄2 oz. The Society of Arts voted their gold medal to the author of the above formula. 2. Add a little solution of acetate of lead to a decoction of madder, to throw down the brown colouring matter, filter, add a solution of tin or alum, precipitate with a solution of carbonate of soda or of potassa, and otherwise proceed as before. 3. (Ure.) Ground madder, 2 lbs.; water, 1 gall.; macerate with agitation for 10 minutes, strain off the water, and press the remainder quite dry; repeat the process a second and a third time; then add to the mixed liquors, alum 1⁄2 lb., dissolved in water, 3 quarts; and heat in a water bath for 3 or 4 hours, adding water as it evaporates; next filter, first through flannel, and, when sufficiently cold, through paper; then add a solution of carbonate of potassa as long as a precipitate falls, which must be washed until the water comes off colourless, and, lastly, dried. If the alkali be added in 3 successive doses, 3 different lakes will be obtained, successively diminishing in beauty. See Madder, Madder, Red, &c. Lake, Or′ange. Prep. Take of the best Spanish annotta, 4 oz.; pearlash, 3⁄4 lb.; water, 1 gall.; boil for half an hour, strain, precipitate with alum, 1 lb., dissolved in water, 1 gall., observing not to add the latter solution when it ceases to produce an effervescence or a precipitate; strain, and dry the sediment in small squares, lozenges, or drops. The addition of some solution of tin turns this lake on the LEMON YELLOW; acids redden it. See Lake, Yellow. Lake, Red. Prep. Take of pearlash, 1 lb.; clean shreds of scarlet cloth, 31⁄2 lbs.; water, 5 galls.; boil till the cloth is decoloured, filter the decoction, and precipitate with a solution of alum, as before. See
  • 64.
    the Lakes noticedabove (Brazil-wood, Carminated, Cochineal, and Madder). Lake, Yellow. Prep. 1. Boil French berries, quercitron bark, or turmeric, 1 lb., and salt of tartar, 1 oz., in water, 1 gall., until reduced to one half, then strain the decoction, and precipitate with a solution of alum. 2. Boil 1 lb. of the dye-stuff with alum, 1⁄2 lb.; water, 1 gall., as before, and precipitate the decoction with a solution of carbonate of potash. See Lake, Orange (above). LAMB in its general qualities closely resembles mutton, of which, indeed, it is merely a younger and more delicate kind. It is well adapted as an occasional article of food for the convalescent and dyspeptic; but it is unequal for frequent use, more especially for the healthy and robust, to the flesh of the adult animal. LAMBS, DISEASES OF. Among other diseases, these animals are particularly prone to one affecting the lungs, in consequence of the existence of parasites (Strongylus bronchialis) in the air- passages. See Parasites. LAMP. A contrivance for producing artificial light or heat by the combustion of inflammable liquids. The term ‘lamp’ is also applied to a portable gas-burner (GAS-LAMP), and to a tubular candle-holder, which, by the aid of a simple mechanical device, keeps the flame at one height (CANDLE-LAMP). Oil lamps were employed for illumination among the nations of antiquity, at the earliest period of which any record exists. The Assyrian, Greek, and Roman lamps preserved in our museums are generally noble specimens of art-workmanship. Though elegant in form, and rich in external embellishment, the ancient lamp was simply a vessel to contain the oil, with a short depression or spout on the one side, in which the wick is laid. Lamps of this rude construction are still in common use in many countries.
  • 65.
    No important improvementin the principle and construction of lamps as a source of light occurred until a comparatively recent date; the smoke, dirt, and disagreeable odour of the common lamp having previously led to its disuse among the superior classes in favour of candles. At length, in 1789, M. Argand made a revolution in illumination by the invention and introduction of the well-known lamp which bears his name. In the Argand lamp a hollow tubular wick of woven cotton replaces the solid bundles of fibres, and is so arranged that air passes through it into the interior of the flame. Over the burner is placed a cylindrical glass chimney, open at the bottom, and surrounding the flame at a short distance from it, by which another current of air is made to act on the exterior portion of the flame. In this way a due supply of oxygen is secured, and sufficient heat generated for the perfect combustion of the gaseous products of the oil, and the smoke and soot which escape from the ordinary lamp are converted into a brilliant and smokeless flame. The earliest table-lamps constructed on Argand’s principle had one serious defect—the oil vessels had to be placed almost on a level with the burners, in a position which caused them to cast objectionable shadows. This defect was almost entirely removed by making the oil vessel in the form of a flattish ring, connected by slender tubes with the burner. The more elegant contrivances, known as the MODERATOR LAMP and Carcel lamp, which are now so much used for burning colza and similar oils, cast no shadow. In these the oil, instead of being sucked up by the wick, or descending to it by the force of gravity, is driven up by mechanical means from the oil-reservoir contained in the foot or pedestal. A spiral spring, acting upon a piston, elevates the oil in the ‘moderator,’ while a little pump worked by clockwork does the same duty in the ‘Carcel.’ The burner and wick in each are formed on Argand’s principle. For burning the hydrocarbon oils distilled from coal and petroleum, lamps of very simple construction are used. These oils, in consequence of their diffusive character, rise to a considerable height up a wick, and therefore do not require mechanical lamps. The wicks
  • 66.
    of HYDRO-CARBON LAMPSare usually flat, but sometimes circular. To cause perfect combustion, a strong draught of air is created by placing over the flame a tall glass chimney, usually much contracted above the flame. A metallic cap, with an orifice the shape of the flame, is placed over the burner, its use being to deflect the currents of air upon the flame. The reservoirs of hydro-carbon lamps ought always to be constructed of some bad conductor of heat, as glass or porcelain.
  • 67.
    For chemical operations,many forms of lamp are used. The ordinary glass SPIRIT-LAMP, fitted with a ground-glass cap, is quite indispensable for minor experiments. (See engr. 1.) Stoneware wick- holders are preferable to those of brass, which become greatly heated, and endanger the splitting of the glass. “An effective spirit- lamp may at any time be constructed out of a vial having a glass tube passing through the cork, a cover being formed from a test- tube inverted over the wick, and fitting with moderate tightness on the superior extremity of the cork” (Greville Williams). Alcohol or wood spirit is the fuel used. The Argand lamp, when intended as a source of heat for chemical purposes, is so modified as to adapt it to burn either oil, spirit of wine, or wood-spirit, and the combustion is greatly aided by the chimney, which in this case is made of copper. (See engr. 2 and 3.) The lamp itself is also made of metal, and furnished with ground caps to the wick-holder and aperture by which the spirit is introduced, in order to prevent loss of spirit by evaporation when the
  • 68.
    lamp is notin use. When in use this aperture must always be left open, otherwise an accident is sure to happen, as the heat expands the air in the lamp, and the spirit is forcibly expelled. In those situations in which coal-gas is cheap, it may be used with great economy and advantage as a source of heat in most chemical operations. Retorts, flasks, capsules, and other vessels, can be thus exposed to an easily regulated and constant temperature for many successive hours. Small platinum crucibles may be ignited to redness by placing them over the flame on a little wire triangle. Of the various gas-lamps now used in the laboratory, the first and most simple consists of a common Argand gas-burner fixed on a heavy and low foot, and connected with a flexible gas-tube of caoutchouc or other material. (See engr. 4.) With this arrangement it is possible to obtain any degree of heat, from that of the smallest blue flame to that which is sufficient to raise a moderately large platinum crucible to dull redness. When gas mixed with a certain proportion of air is burnt, a pale blue flame, free from smoke, and possessing great heating power, is obtained. A lamp for burning the mixture may easily be made by fitting a close cover of fine wire gauze over the top of the chimney of the last-mentioned contrivance. The gas is turned on, and after a few minutes ignited above the wire gauze. (See page 946). The ingenious and useful burners of Bunsen and Griffin are so constructed that gas and air mixed in any proportions, or gas alone, may be burnt at pleasure. Bunsen’s is a most efficient and convenient form of burner. (See illustration on next page.) It consists of a gas jet, surrounded by a metal tube, about 6 to 9 inches high and about 1⁄2 inch in diameter; having at the bottom four large holes. On the admission of air, when the gas is turned on, the air rushes in by these orifices, and mingling with the gas, the mixture ascends to the top of the tube and is there ignited, giving rise to a flame of great heat, but without luminosity, owing to the simultaneous combustion of the carbon and the hydrogen. The burner, however, is so contrived that by shutting off the supply of air entirely, or limiting it, the flame may be made more or less luminous
  • 69.
    at pleasure. Todistribute the flame, a rosette burner is placed on the top of the tube. An improved variety of this burner has been designed by Bunsen, and is figured below.
  • 70.
  • 71.
    Fig. 2.—Improved Bunsenburner. It is so contrived as to give a flame that is a very much better substitute for the flame of the blowpipe, than the ordinary Bunsen’s burner, and may hence be employed for reducing, oxidising, fusing, and volatilising, as well as for the observation of coloured flames. Fig. 1 is a sheath which, by turning round, regulates the admission of air. When it is used the conical chimney, d d d d, is placed in e e; it is of a size sufficient to allow of the flame burning tranquilly. In fig. 1 the flame is represented of half its natural size. This flame it will be seen consists of three divisions, viz.—1, a a a a the dark zone, which is composed of cold gas mixed with about 62 per cent. of air. 2, a c a b the mantle formed by the burning mixture of gas and air. 3, a b a, the luminous tip of the dark cone, which only appears when the orifices for the air are partially closed. Reductions may be performed in this part of the flame.
  • 72.
    Bunsen, however, dividesthe flame into six parts, to which he attributes as many functions. These six divisions of the flame he names as follows:— 1. The base at α has a relatively low temperature, because the burning gas is here cooled by the constant current of fresh air, and also because the lamp itself conducts the heat away. This part of the flame serves for discovering the colours produced by readily volatile bodies, when less volatile matters which colour the flame are also present. At the relatively low temperature of this part of the flame, the former vaporises alone instantaneously, and the resulting colour imparted to the flame is for a moment visible unmixed with other colours. 2. The Fusing Zone. This lies at β, at a distance from the bottom of somewhat more than one third of the height of the flame, equidistant from the outside and the inside of the mantle, which is broadest at this part. This is the hottest part of the flame, viz., about 2300°, and it therefore serves for testing substances, as to their fusibility, volatility, emission of light, and for all processes of fusion at a high temperature. 3. The lower Oxidising Zone lies in the outer border of the fusing zone at γ, and is especially suitable for the oxidation of oxides dissolved in vitreous fluxes. 4. The upper Oxidising Flame at ε consists of the non-luminous tip of the flame. Its action is strongest when the air holes of the lamp are fully open. It is used for the roasting away of volatile products of oxidation, and generally for all processes of oxidation, when the highest temperature is not required. 5. The lower Reducing Zone lies at δ, in the inner border of the fusing zone next to the dark cone. The reducing gases are here mixed with oxygen, and, therefore, do not possess their full power, hence they are without action on many substances which are
  • 73.
    Argand’s lamp, with wire-gauzecap. deoxidised in the upper reducing flame. This part of the flame is especially suited for reduction on charcoal or in vitreous fluxes. 6. The upper Reducing Flame lies at η, in the luminous tip of the dark inner cone, which, as already explained, may be produced by diminishing the supply of air. This part of the flame must not be allowed to get large enough to blacken a test tube filled with water and held in it. It contains no free oxygen, is rich in separated incandescent carbon, and therefore has a much stronger action than the lower reducing zone. It is used more particularly for the reduction of metals collected in the form of incrustations. The subjoined is a drawing of the gauze burner, which is an open cylinder with wire gauze at the top. When this is placed over the gas burner, a supply of air is drawn in at the bottom by the ascending current of gas, and the mixture burns above the gauze, with a very hot flame, quite free from smoke, the metallic meshes preventing the flame from passing down to the gas below. See Illumination, Fuel, Furnace, Gas, Laboratory, &c. Lamp, Flame′less. Syn. Glow lamp. A coil of fine platinum wire is slipped over the wick of a spirit lamp, the greater part being raised above the cotton; the lamp is supplied with ether or alcohol, lighted for a moment and then blown out. The coil continues to glow in the mixed atmosphere of air and combustible vapour, until the liquid in the lamp is exhausted. Lamp, Monochromat′ic. A lamp fed with a mixture of a solution of common salt and spirit of wine. It gives a yellow light, and makes every object illuminated by it appear either yellow or
  • 74.
    black. The humanfeatures are changed in a remarkable degree; the countenance appearing truly ghastly and unearthly. Lamp, Safety. Syn. Miner’s lamp, Davy, Geordy. The safety lamp of Sir H. Davy and George Stephenson are similar in principle, and were independently invented about the same time. That of Sir H. Davy consists of a common oil lamp, surmounted with a cylinder of wire gauze, the apertures of which are not greater than the 1⁄20th of an inch square, and the wire of which it is made to the 1⁄40th to the 1⁄60th of an inch in diameter. (See engr.) The fire-damp (carbonetted hydrogen) along with air passes through the meshes into the interior of the gauze cylinder. Here it ignites, but the flame which is produced by its combustion cannot explode a mixture of fire-damp and air by which the lamp may be surrounded. The flame is prevented from passing to the exterior of the gauze by the cooling action of the metal of which it is constructed. When this lamp is taken into an explosive atmosphere, although the fire-damp may burn within the cage with such energy as sometimes to heat the metallic tissue to dull redness, the flame is not communicated to the mixture on the outside. These appearances are so remarkable, that the lamp becomes an admirable indicator of the state of the air in different parts of the mine, and if its admonitions are attended to, gives the miner time to withdraw before an explosion takes place.
  • 75.
    Lamp, Telescope. Thisingenious contrivance, invented by Messrs Murray and Heath, is intended for microscopic illumination. It consists of three brass tubes, sliding one within the other, the oil vessel being contained in the inner tube. The height of the lamp is regulated to the greatest nicety by simply turning one tube in the other, interior spiral guides preventing all chance of slipping. The great advantage of this arrangement is absence of the stand and bar usually employed for raising and lowering the lamp, which enables it to be used on all sides, and to be brought much closer to the microscope than other lamps. See engr., below.
  • 76.
    LAMP BLACK. SeeBlack pigments. LAMP′REY. Syn. Great lamprey, Seal. This fish is the Petromizon marinus of Linnæus. It generally quits the sea in the spring, for the purpose of spawning, and remains in our rivers for a few months. Its flesh is soft and glutinous, and though esteemed a delicacy, is extremely difficult of digestion, if not otherwise unwholesome. Potted lampreys are usually so highly seasoned as to become a dangerous article of food. Henry I is said to have lost his life from the effects of a surfeit of lampreys.
  • 77.
    LAUDANINE. C20H25NO3. Analkaloid obtained by Hesse from the aqueous extract of opium. It is homologous with morphine and codeine. It dissolves in strong sulphuric acid with a rose-red colour, in strong nitric acid with an orange red colour, and in ferric chloride with emerald green colour. LANTHA′NIUM. La92. A rare metal, discovered by Mosander, associated with oxide of cerium. Oxide of lanthanium is a pale salmon-coloured powder, unaffected by ignition in open vessels. According to Zschiesche the atomic weight of lanthanium is 90·18. See Cerium. LANTHOPINE. C23H25NO4. A base obtained by Hesse in small quantity, associated with other bases from the aqueous extract of opium. It is homologous with papaverine. Strong nitric acid dissolves it, giving rise to an orange red colour. Strong sulphuric acid gives with it a faint violet colour. LA′PIS. [L.] A stone. The term was much employed by the old chemists, and is still commonly applied to several preparations used in medicine. Lapis Causticus. See Potassium. Lapis Divi′nus. Syn. Divine Stone; Lapis ophthalmicus, L.; Pierre divine, Fr. Prep. 1. (Beer.) Verdigris, nitre, and alum, equal parts, melted together. 2. (P. Cod.) Alum, nitre, and blue vitriol, of each 3 oz.; camphor, 1 dr.; as last. 3. (Woolfuss.) Blue vitriol, nitre, alum, and camphor, equal parts, melted together, adding the camphor last. Astringent and detergent. 1 oz., dissolved in water, 1 pint, formed a once celebrated lotion. 1 dr. in water, 1 pint, is still used as a collyrium. Lapis Inferna′lis. See Nitrate of Silver. Lapis Lazu′li. See Ultramarine.
  • 78.
    Welcome to ourwebsite – the perfect destination for book lovers and knowledge seekers. We believe that every book holds a new world, offering opportunities for learning, discovery, and personal growth. That’s why we are dedicated to bringing you a diverse collection of books, ranging from classic literature and specialized publications to self-development guides and children's books. More than just a book-buying platform, we strive to be a bridge connecting you with timeless cultural and intellectual values. With an elegant, user-friendly interface and a smart search system, you can quickly find the books that best suit your interests. Additionally, our special promotions and home delivery services help you save time and fully enjoy the joy of reading. Join us on a journey of knowledge exploration, passion nurturing, and personal growth every day! ebookbell.com