100% found this document useful (3 votes)
24 views

Java 17 Recipes: A Problem-Solution Approach 4th Edition Josh Juneau 2024 Scribd Download

The document promotes the ebook 'Java 17 Recipes: A Problem-Solution Approach, 4th Edition' by Josh Juneau, available for download on ebookmeta.com. It includes links to various other recommended digital products and provides details about the book's content, authors, and copyright information. The book aims to help readers solve problems related to Java 17 through practical solutions and explanations.

Uploaded by

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

Java 17 Recipes: A Problem-Solution Approach 4th Edition Josh Juneau 2024 Scribd Download

The document promotes the ebook 'Java 17 Recipes: A Problem-Solution Approach, 4th Edition' by Josh Juneau, available for download on ebookmeta.com. It includes links to various other recommended digital products and provides details about the book's content, authors, and copyright information. The book aims to help readers solve problems related to Java 17 through practical solutions and explanations.

Uploaded by

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

Get the full ebook with Bonus Features for a Better Reading Experience on ebookmeta.

com

Java 17 Recipes: A Problem-Solution Approach 4th


Edition Josh Juneau

https://ebookmeta.com/product/java-17-recipes-a-problem-
solution-approach-4th-edition-josh-juneau/

OR CLICK HERE

DOWLOAD NOW

Download more ebook instantly today at https://ebookmeta.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Java 17 Recipes: A Problem-Solution Approach 4th Edition


Josh Juneau

https://ebookmeta.com/product/java-17-recipes-a-problem-solution-
approach-4th-edition-josh-juneau/

ebookmeta.com

Java 17 Recipes - A problem-solution approach 4th Edition


Josh Juneau

https://ebookmeta.com/product/java-17-recipes-a-problem-solution-
approach-4th-edition-josh-juneau-2/

ebookmeta.com

Jakarta EE Recipes: A Problem-Solution Approach Josh


Juneau

https://ebookmeta.com/product/jakarta-ee-recipes-a-problem-solution-
approach-josh-juneau/

ebookmeta.com

IoT and Cloud Computing for Societal Good EAI Springer


Innovations in Communication and Computing Jitendra Kumar
Verma
https://ebookmeta.com/product/iot-and-cloud-computing-for-societal-
good-eai-springer-innovations-in-communication-and-computing-jitendra-
kumar-verma/
ebookmeta.com
Young Adult Literature in Action Rose Brock

https://ebookmeta.com/product/young-adult-literature-in-action-rose-
brock/

ebookmeta.com

Crime Criminology 3rd Edition Rob White

https://ebookmeta.com/product/crime-criminology-3rd-edition-rob-white/

ebookmeta.com

You Bet Your Sass Black Paw Wolves 3 1st Edition Melanie
James

https://ebookmeta.com/product/you-bet-your-sass-black-paw-
wolves-3-1st-edition-melanie-james/

ebookmeta.com

Selections from Virgil Aeneid X An Edition for


Intermediate Students Bloomsbury Classical Languages
Christopher Tanfield (Editor)
https://ebookmeta.com/product/selections-from-virgil-aeneid-x-an-
edition-for-intermediate-students-bloomsbury-classical-languages-
christopher-tanfield-editor/
ebookmeta.com

Software Architecture: The Hard Parts: Modern Trade-Off


Analyses for Distributed Architectures 1st Edition Neal
Ford & Mark Richards & Pramod Sadalage & Zhamak Dehghani
https://ebookmeta.com/product/software-architecture-the-hard-parts-
modern-trade-off-analyses-for-distributed-architectures-1st-edition-
neal-ford-mark-richards-pramod-sadalage-zhamak-dehghani/
ebookmeta.com
Santa s Bad Girl Forever Safe The Twelve Days of Christmas
1st Edition Annelise Reynolds

https://ebookmeta.com/product/santa-s-bad-girl-forever-safe-the-
twelve-days-of-christmas-1st-edition-annelise-reynolds/

ebookmeta.com
Java 17
Recipes
A Problem-Solution Approach

Fourth Edition

Josh Juneau
Luciano Manelli
Java 17 Recipes
A Problem-Solution Approach
Fourth Edition

Josh Juneau
Luciano Manelli
Java 17 Recipes: A Problem-Solution Approach
Josh Juneau Luciano Manelli
Hinckley, IL, USA TARANTO, Taranto, Italy

ISBN-13 (pbk): 978-1-4842-7962-5 ISBN-13 (electronic): 978-1-4842-7963-2


https://doi.org/10.1007/978-1-4842-7963-2

Copyright © 2022 by Josh Juneau, Luciano Manelli


This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the
material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation,
broadcasting, reproduction on microfilms or in any other physical way, and transmission or information
storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now
known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with
every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an
editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the
trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not
identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to
proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication,
neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or
omissions that may be made. The publisher makes no warranty, express or implied, with respect to the
material contained herein.
Managing Director, Apress Media LLC: Welmoed Spahr
Acquisitions Editor: Steve Anglin
Development Editor: James Markham
Coordinating Editor: Mark Powers
Copyeditor: Kim Burton
Cover designed by eStudioCalamar
Cover image by Sama Hosseini on Unsplash (www.unsplash.com)
Distributed to the book trade worldwide by Apress Media, LLC, 1 New York Plaza, New York, NY 10004,
U.S.A. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.com, or visit www.
springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science +
Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.
For information on translations, please e-mail booktranslations@springernature.com; for reprint,
paperback, or audio rights, please e-mail bookpermissions@springernature.com.
Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and
licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales
web page at http://www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is available to
readers on GitHub (https://github.com/Apress). For more detailed information, please visit http://www.
apress.com/source-­code.
Printed on acid-free paper
This book is dedicated to my wife and children.
—Josh Juneau

To my daughter, Sara
To my son, Marco
To my mum, Anna
Everyone must always follow their dreams and fight for them.
—Luciano Manelli
Table of Contents
About the Authors�������������������������������������������������������������������������������������������������xxxi

About the Technical Reviewer����������������������������������������������������������������������������xxxiii


Introduction���������������������������������������������������������������������������������������������������������xxxv

Chapter 1: Getting Started with Java 17������������������������������������������������������������������ 1


1-1. Installing Java����������������������������������������������������������������������������������������������������������������������� 1
Problem����������������������������������������������������������������������������������������������������������������������������������� 1
Solution����������������������������������������������������������������������������������������������������������������������������������� 2
How It Works��������������������������������������������������������������������������������������������������������������������������� 3
1-2. Configuring the PATH������������������������������������������������������������������������������������������������������������� 4
Problem����������������������������������������������������������������������������������������������������������������������������������� 4
Solution����������������������������������������������������������������������������������������������������������������������������������� 4
How It Works��������������������������������������������������������������������������������������������������������������������������� 5
1-3. Testing Java��������������������������������������������������������������������������������������������������������������������������� 5
Problem����������������������������������������������������������������������������������������������������������������������������������� 5
Solution����������������������������������������������������������������������������������������������������������������������������������� 5
How It Works��������������������������������������������������������������������������������������������������������������������������� 7
1-4. Installing Eclipse������������������������������������������������������������������������������������������������������������������� 8
Problem����������������������������������������������������������������������������������������������������������������������������������� 8
Solution����������������������������������������������������������������������������������������������������������������������������������� 8
How It Works������������������������������������������������������������������������������������������������������������������������� 11
1-5. Getting to “Hello, World”������������������������������������������������������������������������������������������������������ 12
Problem��������������������������������������������������������������������������������������������������������������������������������� 12
Solution��������������������������������������������������������������������������������������������������������������������������������� 12
How It Works������������������������������������������������������������������������������������������������������������������������� 20
1-6. Configuring the CLASSPATH������������������������������������������������������������������������������������������������ 23

v
Table of Contents

Problem��������������������������������������������������������������������������������������������������������������������������������� 23
Solution��������������������������������������������������������������������������������������������������������������������������������� 23
How It Works������������������������������������������������������������������������������������������������������������������������� 24
1-7. Organizing Code with Packages������������������������������������������������������������������������������������������ 25
Problem��������������������������������������������������������������������������������������������������������������������������������� 25
Solution��������������������������������������������������������������������������������������������������������������������������������� 26
How It Works������������������������������������������������������������������������������������������������������������������������� 27
1-8. Declaring Variables and Access Modifiers��������������������������������������������������������������������������� 29
Problem��������������������������������������������������������������������������������������������������������������������������������� 29
Solution��������������������������������������������������������������������������������������������������������������������������������� 29
How It Works������������������������������������������������������������������������������������������������������������������������� 32
1-9. Converting to and from a String������������������������������������������������������������������������������������������ 33
Problem��������������������������������������������������������������������������������������������������������������������������������� 33
Solution��������������������������������������������������������������������������������������������������������������������������������� 34
How It Works������������������������������������������������������������������������������������������������������������������������� 34
1-10. Passing Arguments via Command-Line Execution������������������������������������������������������������ 35
Problem��������������������������������������������������������������������������������������������������������������������������������� 35
Solution��������������������������������������������������������������������������������������������������������������������������������� 35
How It Works������������������������������������������������������������������������������������������������������������������������� 37
1-11. Accepting Input from the Keyboard����������������������������������������������������������������������������������� 37
Problem��������������������������������������������������������������������������������������������������������������������������������� 37
Solution��������������������������������������������������������������������������������������������������������������������������������� 38
How It Works������������������������������������������������������������������������������������������������������������������������� 39
1-12. Documenting Your Code���������������������������������������������������������������������������������������������������� 41
Problem��������������������������������������������������������������������������������������������������������������������������������� 41
Solution��������������������������������������������������������������������������������������������������������������������������������� 41
How It Works������������������������������������������������������������������������������������������������������������������������� 43
1-13. Reading Environment Variables����������������������������������������������������������������������������������������� 45
Problem��������������������������������������������������������������������������������������������������������������������������������� 45
Solution��������������������������������������������������������������������������������������������������������������������������������� 45
How It Works������������������������������������������������������������������������������������������������������������������������� 46
1-14. Summary��������������������������������������������������������������������������������������������������������������������������� 47

vi
Table of Contents

Chapter 2: Enhancements from Java 9 Through Java 17��������������������������������������� 49


2-1. Introduction to the var Keyword������������������������������������������������������������������������������������������ 49
Problem��������������������������������������������������������������������������������������������������������������������������������� 49
Solution��������������������������������������������������������������������������������������������������������������������������������� 49
How It Works������������������������������������������������������������������������������������������������������������������������� 50
2-2. Reading the Contents of Files���������������������������������������������������������������������������������������������� 51
Problem��������������������������������������������������������������������������������������������������������������������������������� 51
Solution��������������������������������������������������������������������������������������������������������������������������������� 51
How It Works������������������������������������������������������������������������������������������������������������������������� 52
2-3. Writing a Text Block������������������������������������������������������������������������������������������������������������� 53
Problem��������������������������������������������������������������������������������������������������������������������������������� 53
Solution��������������������������������������������������������������������������������������������������������������������������������� 53
How It Works������������������������������������������������������������������������������������������������������������������������� 54
2-4. The Enhancement of NullPointerException�������������������������������������������������������������������������� 54
Problem��������������������������������������������������������������������������������������������������������������������������������� 54
Solution��������������������������������������������������������������������������������������������������������������������������������� 54
How It Works������������������������������������������������������������������������������������������������������������������������� 55
2-5. Pattern Matching for instanceof������������������������������������������������������������������������������������������ 55
Problem��������������������������������������������������������������������������������������������������������������������������������� 55
Solution��������������������������������������������������������������������������������������������������������������������������������� 55
How It Works������������������������������������������������������������������������������������������������������������������������� 56
2-6. Using Record����������������������������������������������������������������������������������������������������������������������� 56
Problem��������������������������������������������������������������������������������������������������������������������������������� 56
Solution��������������������������������������������������������������������������������������������������������������������������������� 56
How It Works������������������������������������������������������������������������������������������������������������������������� 58
2-7. Restore Always-Strict Floating-Point Semantics����������������������������������������������������������������� 59
Problem��������������������������������������������������������������������������������������������������������������������������������� 59
Solution��������������������������������������������������������������������������������������������������������������������������������� 59
How It Works������������������������������������������������������������������������������������������������������������������������� 60

vii
Table of Contents

2-8. Pseudorandom Number Generators������������������������������������������������������������������������������������ 60


Problem��������������������������������������������������������������������������������������������������������������������������������� 60
Solution��������������������������������������������������������������������������������������������������������������������������������� 60
How It Works������������������������������������������������������������������������������������������������������������������������� 62
2-9. Sealed Classes�������������������������������������������������������������������������������������������������������������������� 62
Problem��������������������������������������������������������������������������������������������������������������������������������� 62
Solution��������������������������������������������������������������������������������������������������������������������������������� 62
How It Works������������������������������������������������������������������������������������������������������������������������� 63
2-10. The Vector API�������������������������������������������������������������������������������������������������������������������� 63
Problem��������������������������������������������������������������������������������������������������������������������������������� 63
Solution��������������������������������������������������������������������������������������������������������������������������������� 63
How It Works������������������������������������������������������������������������������������������������������������������������� 65
2-11. Avoiding Redundancy in Interface Code���������������������������������������������������������������������������� 66
Problem��������������������������������������������������������������������������������������������������������������������������������� 66
Solution��������������������������������������������������������������������������������������������������������������������������������� 66
How It Works������������������������������������������������������������������������������������������������������������������������� 67
2-12. Easily Retrieving Information on OS Processes����������������������������������������������������������������� 68
Problem��������������������������������������������������������������������������������������������������������������������������������� 68
Solution��������������������������������������������������������������������������������������������������������������������������������� 68
How It Works������������������������������������������������������������������������������������������������������������������������� 70
2-13. Handling try-with-resources Construct����������������������������������������������������������������������������� 71
Problem��������������������������������������������������������������������������������������������������������������������������������� 71
Solution��������������������������������������������������������������������������������������������������������������������������������� 71
How It Works������������������������������������������������������������������������������������������������������������������������� 72
2-14. Filtering Data Before and After a Condition with Streams������������������������������������������������� 72
Problem��������������������������������������������������������������������������������������������������������������������������������� 72
Solution��������������������������������������������������������������������������������������������������������������������������������� 72
How It Works������������������������������������������������������������������������������������������������������������������������� 74
2-15. Utilizing Factory Methods to Create Immutable Collections���������������������������������������������� 74
Problem��������������������������������������������������������������������������������������������������������������������������������� 74
Solution��������������������������������������������������������������������������������������������������������������������������������� 75
How It Works������������������������������������������������������������������������������������������������������������������������� 76
viii
Table of Contents

2-16. Pattern Matching for switch (Preview)������������������������������������������������������������������������������ 76


Problem��������������������������������������������������������������������������������������������������������������������������������� 76
Solution��������������������������������������������������������������������������������������������������������������������������������� 76
How It Works������������������������������������������������������������������������������������������������������������������������� 77
2-17. Summary��������������������������������������������������������������������������������������������������������������������������� 78

Chapter 3: Strings��������������������������������������������������������������������������������������������������� 79
3-1. Compact Strings������������������������������������������������������������������������������������������������������������������ 79
3-2. Obtaining a Subsection of a String�������������������������������������������������������������������������������������� 79
Problem��������������������������������������������������������������������������������������������������������������������������������� 79
Solution��������������������������������������������������������������������������������������������������������������������������������� 80
How It Works������������������������������������������������������������������������������������������������������������������������� 80
3-3. Comparing Strings��������������������������������������������������������������������������������������������������������������� 81
Problem��������������������������������������������������������������������������������������������������������������������������������� 81
Solution��������������������������������������������������������������������������������������������������������������������������������� 81
How It Works������������������������������������������������������������������������������������������������������������������������� 83
3-4. Trimming Whitespace���������������������������������������������������������������������������������������������������������� 85
Problem��������������������������������������������������������������������������������������������������������������������������������� 85
Solution��������������������������������������������������������������������������������������������������������������������������������� 85
How It Works������������������������������������������������������������������������������������������������������������������������� 85
3-5. Discovering Blank Strings��������������������������������������������������������������������������������������������������� 86
Problem��������������������������������������������������������������������������������������������������������������������������������� 86
Solution��������������������������������������������������������������������������������������������������������������������������������� 86
How It Works������������������������������������������������������������������������������������������������������������������������� 86
3-6. Stripping Whitespace���������������������������������������������������������������������������������������������������������� 87
Problem��������������������������������������������������������������������������������������������������������������������������������� 87
Solution��������������������������������������������������������������������������������������������������������������������������������� 87
How It Works������������������������������������������������������������������������������������������������������������������������� 88
3-7. Breaking String Lines���������������������������������������������������������������������������������������������������������� 88
Problem��������������������������������������������������������������������������������������������������������������������������������� 88
Solution��������������������������������������������������������������������������������������������������������������������������������� 88
How It Works������������������������������������������������������������������������������������������������������������������������� 89

ix
Table of Contents

3-8. Repeating Strings���������������������������������������������������������������������������������������������������������������� 89


Problem��������������������������������������������������������������������������������������������������������������������������������� 89
Solution��������������������������������������������������������������������������������������������������������������������������������� 89
How It Works������������������������������������������������������������������������������������������������������������������������� 89
3-9. Changing the Case of a String��������������������������������������������������������������������������������������������� 89
Problem��������������������������������������������������������������������������������������������������������������������������������� 89
Solution��������������������������������������������������������������������������������������������������������������������������������� 90
How It Works������������������������������������������������������������������������������������������������������������������������� 90
3-10. Concatenating Strings������������������������������������������������������������������������������������������������������� 91
Problem��������������������������������������������������������������������������������������������������������������������������������� 91
Solution 1������������������������������������������������������������������������������������������������������������������������������ 91
Solution 2������������������������������������������������������������������������������������������������������������������������������ 91
Solution 3������������������������������������������������������������������������������������������������������������������������������ 92
How It Works������������������������������������������������������������������������������������������������������������������������� 92
3-11. Converting Strings to Numeric Values������������������������������������������������������������������������������� 93
Problem��������������������������������������������������������������������������������������������������������������������������������� 93
Solution 1������������������������������������������������������������������������������������������������������������������������������ 93
Solution 2������������������������������������������������������������������������������������������������������������������������������ 94
How It Works������������������������������������������������������������������������������������������������������������������������� 94
3-12. Iterating Over the Characters of a String��������������������������������������������������������������������������� 95
Problem��������������������������������������������������������������������������������������������������������������������������������� 95
Solution��������������������������������������������������������������������������������������������������������������������������������� 95
How It Works������������������������������������������������������������������������������������������������������������������������� 97
3-13. Finding Text Matches��������������������������������������������������������������������������������������������������������� 97
Problem��������������������������������������������������������������������������������������������������������������������������������� 97
Solution 1������������������������������������������������������������������������������������������������������������������������������ 97
Solution 2������������������������������������������������������������������������������������������������������������������������������ 99
How It Works������������������������������������������������������������������������������������������������������������������������� 99
3-14. Replacing All Text Matches���������������������������������������������������������������������������������������������� 101
Problem������������������������������������������������������������������������������������������������������������������������������� 101
Solution������������������������������������������������������������������������������������������������������������������������������� 101
How It Works����������������������������������������������������������������������������������������������������������������������� 102
x
Table of Contents

3-15. Determining Whether a File Suffix Matches a Given String��������������������������������������������� 102


Problem������������������������������������������������������������������������������������������������������������������������������� 102
Solution������������������������������������������������������������������������������������������������������������������������������� 103
How It Works����������������������������������������������������������������������������������������������������������������������� 103
3-16. Making a String That Can Contain Dynamic Information������������������������������������������������� 104
Problem������������������������������������������������������������������������������������������������������������������������������� 104
Solution 1���������������������������������������������������������������������������������������������������������������������������� 104
Solution 2���������������������������������������������������������������������������������������������������������������������������� 104
How It Works����������������������������������������������������������������������������������������������������������������������� 105
3-17. Summary������������������������������������������������������������������������������������������������������������������������� 106

Chapter 4: Numbers and Dates����������������������������������������������������������������������������� 107


4-1. Rounding Float and Double Values to Integers������������������������������������������������������������������ 107
Problem������������������������������������������������������������������������������������������������������������������������������� 107
Solution������������������������������������������������������������������������������������������������������������������������������� 107
How It Works����������������������������������������������������������������������������������������������������������������������� 108
4-2. Formatting Double and Long Decimal Values�������������������������������������������������������������������� 110
Problem������������������������������������������������������������������������������������������������������������������������������� 110
Solution������������������������������������������������������������������������������������������������������������������������������� 110
How It Works����������������������������������������������������������������������������������������������������������������������� 110
4-3. Formatting Compact Number�������������������������������������������������������������������������������������������� 112
Problem������������������������������������������������������������������������������������������������������������������������������� 112
Solution������������������������������������������������������������������������������������������������������������������������������� 112
How It Works����������������������������������������������������������������������������������������������������������������������� 112
4-4. Comparing int Values��������������������������������������������������������������������������������������������������������� 113
Problem������������������������������������������������������������������������������������������������������������������������������� 113
Solution 1���������������������������������������������������������������������������������������������������������������������������� 113
Solution 2���������������������������������������������������������������������������������������������������������������������������� 113
How It Works����������������������������������������������������������������������������������������������������������������������� 114
4-5. Comparing Floating-Point Numbers���������������������������������������������������������������������������������� 115
Problem������������������������������������������������������������������������������������������������������������������������������� 115
Solution 1���������������������������������������������������������������������������������������������������������������������������� 115

xi
Table of Contents

Solution 2���������������������������������������������������������������������������������������������������������������������������� 116


How It Works����������������������������������������������������������������������������������������������������������������������� 116
4-6. Randomly Generating Values��������������������������������������������������������������������������������������������� 116
Problem������������������������������������������������������������������������������������������������������������������������������� 116
Solution 1���������������������������������������������������������������������������������������������������������������������������� 117
Solution 2���������������������������������������������������������������������������������������������������������������������������� 118
How It Works����������������������������������������������������������������������������������������������������������������������� 118
4-7. Obtaining the Current Date Without Time�������������������������������������������������������������������������� 119
Problem������������������������������������������������������������������������������������������������������������������������������� 119
Solution������������������������������������������������������������������������������������������������������������������������������� 119
How It Works����������������������������������������������������������������������������������������������������������������������� 119
4-8. Obtaining a Date Object Given Date Criteria���������������������������������������������������������������������� 120
Problem������������������������������������������������������������������������������������������������������������������������������� 120
Solution������������������������������������������������������������������������������������������������������������������������������� 120
How It Works����������������������������������������������������������������������������������������������������������������������� 121
4-9. Obtaining a Year-Month-Day Date Combination���������������������������������������������������������������� 121
Problem������������������������������������������������������������������������������������������������������������������������������� 121
Solution 1���������������������������������������������������������������������������������������������������������������������������� 121
Solution 2���������������������������������������������������������������������������������������������������������������������������� 122
How It Works����������������������������������������������������������������������������������������������������������������������� 123
4-10. Obtaining and Calculating Times Based on the Current Time������������������������������������������ 123
Problem������������������������������������������������������������������������������������������������������������������������������� 123
Solution������������������������������������������������������������������������������������������������������������������������������� 123
How It Works����������������������������������������������������������������������������������������������������������������������� 125
4-11. Obtaining and Using the Date and Time Together������������������������������������������������������������ 126
Problem������������������������������������������������������������������������������������������������������������������������������� 126
Solution 1���������������������������������������������������������������������������������������������������������������������������� 126
Solution 2���������������������������������������������������������������������������������������������������������������������������� 128
Solution 3���������������������������������������������������������������������������������������������������������������������������� 129
How It Works����������������������������������������������������������������������������������������������������������������������� 130

xii
Table of Contents

4-12. Obtaining a Machine Timestamp������������������������������������������������������������������������������������� 131


Problem������������������������������������������������������������������������������������������������������������������������������� 131
Solution������������������������������������������������������������������������������������������������������������������������������� 132
How It Works����������������������������������������������������������������������������������������������������������������������� 132
4-13. Converting Dates and Times Based on he Time Zone������������������������������������������������������ 133
Problem������������������������������������������������������������������������������������������������������������������������������� 133
Solution������������������������������������������������������������������������������������������������������������������������������� 133
How It Works����������������������������������������������������������������������������������������������������������������������� 135
4-14. Comparing Two Dates������������������������������������������������������������������������������������������������������ 136
Problem������������������������������������������������������������������������������������������������������������������������������� 136
Solution������������������������������������������������������������������������������������������������������������������������������� 137
How It Works����������������������������������������������������������������������������������������������������������������������� 138
4-15. Finding the Interval Between Dates and Times��������������������������������������������������������������� 138
Problem������������������������������������������������������������������������������������������������������������������������������� 138
Solution 1���������������������������������������������������������������������������������������������������������������������������� 138
Solution 2���������������������������������������������������������������������������������������������������������������������������� 139
How It Works����������������������������������������������������������������������������������������������������������������������� 141
4-16. Obtaining Date-Time from a Specified String������������������������������������������������������������������ 141
Problem������������������������������������������������������������������������������������������������������������������������������� 141
Solution������������������������������������������������������������������������������������������������������������������������������� 142
How It Works����������������������������������������������������������������������������������������������������������������������� 143
4-17. Formatting Dates for Display������������������������������������������������������������������������������������������� 143
Problem������������������������������������������������������������������������������������������������������������������������������� 143
Solution 1���������������������������������������������������������������������������������������������������������������������������� 143
Solution 2���������������������������������������������������������������������������������������������������������������������������� 144
How It Works����������������������������������������������������������������������������������������������������������������������� 146
4-18. Writing Readable Numeric Literals���������������������������������������������������������������������������������� 147
Problem������������������������������������������������������������������������������������������������������������������������������� 147
Solution������������������������������������������������������������������������������������������������������������������������������� 147
How It Works����������������������������������������������������������������������������������������������������������������������� 148

xiii
Table of Contents

4-19. Declaring Binary Literals������������������������������������������������������������������������������������������������� 148


Problem������������������������������������������������������������������������������������������������������������������������������� 148
Solution������������������������������������������������������������������������������������������������������������������������������� 148
How It Works����������������������������������������������������������������������������������������������������������������������� 149
4-20. Period of Day������������������������������������������������������������������������������������������������������������������� 149
Problem������������������������������������������������������������������������������������������������������������������������������� 149
Solution������������������������������������������������������������������������������������������������������������������������������� 149
How It Works����������������������������������������������������������������������������������������������������������������������� 150
4-21. Summary������������������������������������������������������������������������������������������������������������������������� 150

Chapter 5: Object-Oriented Java�������������������������������������������������������������������������� 151


5-1. Controlling Access to Members of a Class������������������������������������������������������������������������ 151
Problem������������������������������������������������������������������������������������������������������������������������������� 151
Solution������������������������������������������������������������������������������������������������������������������������������� 151
How It Works����������������������������������������������������������������������������������������������������������������������� 152
5-2. Making Private Fields Accessible to Other Classes����������������������������������������������������������� 152
Problem������������������������������������������������������������������������������������������������������������������������������� 152
Solution������������������������������������������������������������������������������������������������������������������������������� 152
How It Works����������������������������������������������������������������������������������������������������������������������� 153
5-3. Creating a Class with a Single Instance���������������������������������������������������������������������������� 154
Problem������������������������������������������������������������������������������������������������������������������������������� 154
Solution 1���������������������������������������������������������������������������������������������������������������������������� 154
Solution 2���������������������������������������������������������������������������������������������������������������������������� 156
How It Works����������������������������������������������������������������������������������������������������������������������� 158
5-4. Generating Instances of a Class���������������������������������������������������������������������������������������� 159
Problem������������������������������������������������������������������������������������������������������������������������������� 159
Solution������������������������������������������������������������������������������������������������������������������������������� 159
How It Works����������������������������������������������������������������������������������������������������������������������� 164
5-5. Creating Reusable Objects������������������������������������������������������������������������������������������������ 165
Problem������������������������������������������������������������������������������������������������������������������������������� 165
Solution������������������������������������������������������������������������������������������������������������������������������� 165
How It Works����������������������������������������������������������������������������������������������������������������������� 167

xiv
Table of Contents

5-6. Defining an Interface for a Class��������������������������������������������������������������������������������������� 168


Problem������������������������������������������������������������������������������������������������������������������������������� 168
Solution������������������������������������������������������������������������������������������������������������������������������� 168
How It Works����������������������������������������������������������������������������������������������������������������������� 168
5-7. Modifying Interfaces Without Breaking Existing Code������������������������������������������������������� 171
Problem������������������������������������������������������������������������������������������������������������������������������� 171
Solution������������������������������������������������������������������������������������������������������������������������������� 171
How It Works����������������������������������������������������������������������������������������������������������������������� 172
5-8. Constructing Instances of the Same Class with Different Values�������������������������������������� 173
Problem������������������������������������������������������������������������������������������������������������������������������� 173
Solution������������������������������������������������������������������������������������������������������������������������������� 173
How It Works����������������������������������������������������������������������������������������������������������������������� 177
5-9. Interacting with a Class via Interfaces������������������������������������������������������������������������������ 178
Problem������������������������������������������������������������������������������������������������������������������������������� 178
Solution������������������������������������������������������������������������������������������������������������������������������� 179
How It Works����������������������������������������������������������������������������������������������������������������������� 180
5-10. Making a Class Cloneable����������������������������������������������������������������������������������������������� 181
Problem������������������������������������������������������������������������������������������������������������������������������� 181
Solution������������������������������������������������������������������������������������������������������������������������������� 181
How It Works����������������������������������������������������������������������������������������������������������������������� 185
5-11. Comparing Objects���������������������������������������������������������������������������������������������������������� 187
Problem������������������������������������������������������������������������������������������������������������������������������� 187
Solution 1���������������������������������������������������������������������������������������������������������������������������� 187
Solution 2���������������������������������������������������������������������������������������������������������������������������� 188
How It Works����������������������������������������������������������������������������������������������������������������������� 192
5-12. Extending the Functionality of a Class���������������������������������������������������������������������������� 194
Problem������������������������������������������������������������������������������������������������������������������������������� 194
Solution������������������������������������������������������������������������������������������������������������������������������� 194
How It Works����������������������������������������������������������������������������������������������������������������������� 197
5-13. Defining a Template for Classes to Extend���������������������������������������������������������������������� 197
Problem������������������������������������������������������������������������������������������������������������������������������� 197

xv
Another Random Document on
Scribd Without Any Related Topics
“The little dear,” sighed the old lady. “You won’t catch the
lumbago, Flossie. Little girls don’t catch the lumbago.”
“No, but maybe the lumbago will catch me!” and Flossie still
sobbed. “Shut the door, Nan, and keep the lumbago out!”
Then Nan laughed and said:
“Why, I do believe she thinks the lumbago is a sort of animal! Do
you, Flossie?”
“Ye-ye-yes,” was the halting answer. “Isn’t the lumbago like the
wolf in Little Red Riding Hood?”
“Bless your heart, no!” chuckled Mrs. Pry, in as jolly a manner as
she could, though it hurt her to laugh. “The lumbago is something
like rheumatism. It catches one in the back and keeps them in bed.
I’ve had it before. I’ll be better in a few days. Bless you! the
lumbago isn’t a wolf, though it pains a lot. Don’t be afraid. Though I
don’t know what you are going to do, Nan. I’m not able to get out of
bed, I’m afraid.”
“I’ll manage all right,” Nan said, though her heart was sinking
with all the troubles that seemed flocking around. “I’ll make you
some coffee, as I do when mother has a headache.”
“Do you think you can, my dear?” asked Aunt Sallie. “I’m so sorry
I’m laid up with this lumbago!”
“I can manage,” replied Nan bravely, while she hurried with her
dressing. “We children will just have to keep house by ourselves in
real earnest,” she said to herself.
Nan was helping Flossie dress, and then she intended to hurry
down to the kitchen to make coffee. Nan could get up a simple
breakfast, her mother and Dinah having taught her this. But as Nan
fastened Flossie’s buttons she heard Bert moving around in his
room.
“Whoop-ee!” yelled the boy as he danced around his apartment.
“Oh, look, Freddie! It’s snowing like anything! It’s a regular blizzard!”
“Oh, let me see!” begged the small Bobbsey lad.
“Don’t run around barefooted!” warned Nan from her room. “I
don’t want you catching cold, Freddie, for then I’ll have some one
else sick to nurse.”
“Oh, is Flossie sick?” called Bert who, having looked from the
window to see that it was snowing hard, had now begun to dress.
“Is Flossie sick?” he called again.
“No. It’s Mrs. Pry,” Nan answered. “She has the lumbago in her
back, and I’ll have to stay home from school and nurse her. You and
Flossie and Freddie can go, Bert—that is, if the storm isn’t too bad.
But you’ll have to hurry. We’re late!”
“Late! I should say we were late!” cried Bert as he looked at a
clock on his bureau. “It’s after half past eight and——”
Just then, above the noise of the swirling snowflakes hitting
against the windows and the sound of the howling, cold wind,
another noise came to the ears of the Bobbsey twins.
A bell rang out in the distance. Five strokes were sounded, then a
pause and five strokes more. Another pause, then another five
strokes.
“It’s the storm signal on the school bell!” cried Bert. “The three
fives! Hurray, no school to-day!”
He danced around the room, half dressed.
“Are you sure?” asked careful Nan.
“Sure!” answered Bert. “There it goes again!”
There was no doubt of it this time. Fifteen strokes rang out, five
strokes at a time. It was the signal Mr. Tarton had told the children
to listen for in case of a storm. And this surely was a storm! The
wind blew harder and the swirling, white flakes came down more
thickly.
“No school! No school!” sang Freddie as he began to dress.
“No school! No school!” echoed Flossie, as she followed Nan to
the kitchen.
“Hush, my dears, not so much racket!” begged Nan in a low
voice. “Mrs. Pry is sick, and she may not like noise.”
“Oh, I’m not fussy that way,” said the old lady who, in spite of her
deafness, seemed to have heard what Nan said. “Don’t keep the
children quiet on my account. And you’ll have to hurry, Nan, or
they’ll be late for school.”
“There isn’t any school,” Nan said.
“What’s that—some one fell over a stool?” cried Mrs. Pry. “Oh,
dear! And me flat on my back with lumbago! Who fell over the stool,
Nan?”
“Nobody,” answered the Bobbsey girl. “I said there was no
school!”
“Oh! No school! You mustn’t mumble your words, my dear. I can
hear every time if you speak out. No school, eh? I’m glad of that, for
if there was, you’d be late and on account of me. Oh, dear, I wish I
could be around to help with the work!”
“We’ll do the work, Aunt Sallie,” said Nan kindly. “Don’t you worry
or fuss. Just stay in bed and keep warm, and I’ll bring you up some
breakfast. Would you like a hot flatiron for your back?”
“Well, it would help the misery a lot,” the old lady answered. “But
I don’t like to be such a bother.”
“It isn’t any bother at all,” said Nan kindly. “Bert will help me get
breakfast, won’t you, Bert?”
“Sure,” he answered, sliding down the banister rail. “But I’ve got
to shovel the walks of snow.”
“They can wait,” said Nan. “There’s no use shoveling walks until it
stops snowing.”
“I guess maybe that’s right,” agreed her brother. “Say, it’s a big
storm,” he cried, as he saw how much snow had fallen in the night.
“I hope father and mother are all right—and Sam and Dinah, too.”
“Yes, so do I,” agreed Nan. “And I hope some mail comes in to-
day. I’d love to have a letter from mother.”
Flossie and Freddie crowded eagerly to the windows to look out
at the storm. The house was snug and warm, but outside it was cold
and blowy, and though the small twins did not mind snow or cold
weather they were just as glad, this morning, that they did not have
to tramp out to school.
Nan had often watched her mother and Dinah get breakfast, and
so had Bert, so together the two older Bobbsey twins soon had
coffee boiling on the stove, and the oatmeal which had been made
ready the night before was being warmed.
“I’m going to fry me some bacon!” declared Bert.
“Do you know how?” asked Nan.
“Sure I do,” he declared. “Once Charlie Mason and I made a fire
in the woods and fried bacon. It was good, too.”
“Well, first I wish you’d get some oranges out of the pantry for
Flossie and Freddie,” said Nan. “Do that while I’m taking Mrs. Pry up
this hot coffee,” she added, as she filled a cup with the steaming
drink and put some slices of bread and butter on a tray.
“All right—the oranges will be ready in a minute,” laughed Bert.
“First call for breakfast! First call for breakfast!” he shouted, as he
had heard the waiters in the dining car announce as they came into
the Pullman coaches on the railroad.
“It’s fun being snowed-in like this, isn’t it, Flossie?” asked Freddie,
as he tried to see how flat he could make his nose by pressing it
against the window.
“Lots of fun,” agreed the little girl. “But I’m hungry. I want my
breakfast, Nan.”
“Bert will give you your oranges now,” Nan answered. “And I’ll
dish out your oatmeal when I come down after I take Mrs. Pry her
coffee.”
This satisfied the smaller twins, and they laughed at the funny
faces Bert made as he went about, pretending he was a Pullman
waiter. In fact Freddie laughed so hard that some of his orange went
down the “wrong throat” and Bert had to pat his small brother on
the back to stop the choking.
Nan carried the coffee into Aunt Sallie’s room. Mrs. Pry had not
gotten out of bed and the shades were drawn down over the
windows.
“Shall I make it lighter for you?” asked Nan. “It’s snowing again.”
“What’s that? You say the pig is out of the pen? Land sakes, child,
I didn’t know you kept a pig! Dear me, and Sam isn’t here to chase
him back into the pen! Oh, the misery in my back! If it wasn’t for the
lumbago I’d get after the pig!”
“I didn’t say anything about a pig or a pen,” answered Nan, trying
not to laugh. “I said it was snowing again!”
“Oh, snowing again,” Mrs. Pry remarked. “Well, why didn’t you
say so at first, my dear? Dear me! We’re having a lot of snow this
winter, and early, too. That’s right; raise the curtains so I can see
out. And thank you for the coffee. Ah, it makes me feel better,” she
said, as she sipped it.
“Is it all right and strong enough?” asked Nan.
“Plenty strong, and very good, my dear. You’re quite a little
housekeeper.”
Nan thought that she would need to be, and so would Bert, if
they were to be left alone with a sick woman to look after. But Nan
said nothing about this.
She helped Mrs. Pry sit up in bed, for the old lady could hardly
raise herself on account of the pain in her back. Nan propped the
pillows up against her, and then started downstairs to get the hot
flatiron, leaving Mrs. Pry sipping the coffee and eating the bread and
butter.
As Nan started down she heard the shrill voices of Flossie and
Freddie, and she heard Bert calling:
“Come back in here! Come right back in, you little tykes!”
“Oh, what are they doing now?” thought poor Nan.
CHAPTER XIII

SNOWED IN
Nan Bobbsey was glad her brother Bert was at home, helping her
keep house. Without Bert she felt that she never could look after
things, see to Flossie and Freddie and nurse the sick Mrs. Pry. And
when Nan heard her small brother and sister squealing this way,
which always meant mischief of some sort or other, she was more
than glad that she also heard Bert’s voice calling to the small twins.
Nan got to the foot of the stairs in time to see Bert running out of
a side door after Flossie and Freddie who, bare-headed and with no
wraps on, had run out into the storm.
“Oh, you mustn’t do that!” exclaimed Nan. “Bring them in, Bert!”
“That’s what I’m trying to do,” he answered, but he could not help
laughing, so jolly and full of fun were Flossie and Freddie, though
they were also full of mischief.
“Now, I have you!” cried Bert as he caught Flossie before she had
time to get very far away from the bottom of the steps.
“But you haven’t got me!” shouted Freddie, making a dash
through the piles of snow on the ground and also through the cloud
of swirling flakes falling from the sky. “You haven’t got me!”
“But I will get you!” shouted Bert. “Here, Nan,” he called to his
older sister, “you hold this little tyke while I chase after this Freddie
boy!”
Nan, with a sigh and yet with a little laugh, held Flossie, who,
truth to tell, was herself laughing and giggling so hard at the trick
she and Freddie had played on Bert that she could not have run
much farther, no matter how much she wanted to.
Freddie had counted on Bert having to drag Flossie along with
him on the second part of the chase. But when Bert turned Flossie
over to Nan, that left him free to run, and he caught his small
brother before the latter had taken more than half a dozen steps.
“Prisoner number two!” cried Bert, picking Freddie up in his arms
and carrying him back to the house. “Lock ’em up, Nan!”
“I shall have to, if they aren’t better,” Nan said, with a shake of
her head as she put Flossie down in the hall while Bert did the same
with Freddie.
“No, you don’t!” suddenly cried Bert, as he locked the door out of
which the mischievous ones had darted. He saw Freddie making a
sly attempt to open it again.
“What happened?” asked Nan. “I was coming down to get the
flatiron for Aunt Sallie and I heard the children scream.”
“They were only yelling for fun and because they played a trick on
me,” laughed Bert. “They wanted to go out and get some snow, but
I wouldn’t let them.”
“Of course not!” agreed Nan. “The idea!”
“But we got out, anyhow, didn’t we, Flossie?” laughed Freddie.
“Yes, we did!” she giggled.
“I went to the front door to see if the man had left the milk,”
explained Bert, “for he leaves it on the front steps when it storms
too much to come around to the back. And when I opened the door
these two prisoners,” and laughingly he shook a finger at them,
“wanted to go out and get some snow to bring in the house.
“I said they couldn’t, and I only had time to get the door shut to
keep them in. Then I went to the side door, leaving them trying to
unlock the front door, which they couldn’t do, because I took the key
out,” and with another laugh Bert held up the key. “But all of a
sudden they crawled past me while I was looking on the side porch
for the milk, and that’s how they got out. I had to run after them.”
“I was wondering what happened,” said Nan. “Did you bring the
milk in, Bert?”
“No, I didn’t Nan. There isn’t any milk.”
“Oh, didn’t the milkman come?”
“Guess he didn’t,” Bert answered. “It isn’t the first time he’s
missed us in a storm.”
“Well, I think we have enough left for to-day,” said Nan. “I’m
pretty sure there is a bottle in the pantry. But if he doesn’t leave any
to-morrow, Bert, you’ll have to go after some. But I guess the storm
will stop by then.”
“I don’t know,” said Bert, while again he shook his finger at
Flossie and Freddie who were laughing together in a corner, plotting
more tricks, it is likely. “It looks as if it’s going to snow for a week,
Nan.”
“Oh, I hope it doesn’t do that!” she cried. “Mother and father
would never get home and we’ll never have any word from them.”
“I guess there’d be some way out,” answered Bert. “But I don’t
believe there’ll be any mail delivered to-day. I could go down to the
post-office after it, though.”
“No, I don’t want you to go out in the storm!” objected Nan. “I
don’t want to be left here all alone, with Mrs. Pry sick. Maybe you
couldn’t get back.”
“I’ll stay with you,” promised her brother good-naturedly. “But is
Aunt Sallie very sick?”
“Well, she has lots of pain in her back,” explained Nan. “That’s
why I’m going to take her the hot flatiron. Then I must wash the
dishes and see about getting lunch.”
“Could we play picnic and make believe take our lunch to the
woods to eat?” asked Flossie.
“Oh, that would be lots of fun!” cried Freddie. “We could make
believe up in the attic was woods. Let’s do that!”
“I’ll see about it,” answered Nan. “Now you look after them a little
while, Bert, and I’ll take this iron to Aunt Sallie. And don’t you two
little tykes dare to run out in the snow again!”
“We won’t,” promised Flossie.
Nan found the old lady moving restlessly about in bed with the
pain of the lumbago in her back.
“Do you think I ought to get the doctor for you?” asked the girl.
“Oh, no, dearie, I’ll be all right in a day or so,” answered Mrs. Pry.
“This hot iron will help a lot. Then if I had some of my liniment to
rub on my back, I’d feel better.”
“Shall I get Bert to go to the drug store after the liniment?” asked
Nan.
“You won’t need to do that, dearie,” answered Mrs. Pry. “I have
some of the stuff in a bottle in my valise. If you’ll hand it to me I’ll
rub it on my back, and then I’ll go to sleep awhile. I didn’t sleep
much all night. But I fell asleep toward morning, and I slept so hard
I didn’t wake up in time to call you to go to school.”
“Well, there isn’t any school, so that didn’t matter,” Nan said.
She found the bottle of queer-smelling liniment in the old lady’s
valise, and gave it to her. Then Nan said:
“Well, I’ll go down now and wash the dishes.”
“What’s that?” exclaimed Mrs. Pry. “You say Bert is going out and
try to catch some fishes? Land sakes, child! he never can catch any
fishes in this snow storm! Don’t let him go! Besides, I don’t like fish,
anyhow!”
“I didn’t say anything about fishes!” replied Nan in louder tones.
“I said I was going to wash the dishes!”
“Oh! Dishes!” murmured Mrs. Pry. “Well, my hearing isn’t what it
once was. But I surely thought you said fishes.”
Holding back her merriment, Nan went downstairs. Flossie and
Freddie were so filled with joy over their plan of going up in the attic
and playing they were on a picnic in the woods that they had
become very good and quiet indeed, making no trouble for Bert,
who had “picked up” the dishes, ready for washing.
“I’ll dry them for you,” he told Nan, and he added: “We might as
well give Flossie and Freddie some crackers and cookies, and let
them play up in the attic where they won’t bother Aunt Sallie.
They’ve got to do something to keep out of trouble, and they can’t
go out in the storm.”
“Yes, we’ll do that,” decided Nan.
Accordingly, she put some odds and ends of cookies, cakes and
crackers in two boxes and gave them to the smaller twins. Then
Flossie got one of her dolls and Freddie took a little iron fire-engine,
one of his favorite toys, and the small twins went up to the attic.
Nan went up with them and remained a little while, to be sure it was
warm enough for them.
“I’ll keep up a good fire,” Bert had promised, and he was as good
as his word, for the attic was as “warm as toast.” Bert knew how to
put coal on the furnace, and though he could not toss on quite as
big shovelfuls as could Sam, who always looked after the heater,
Bert did very well.
With the small twins thus out of the way for a while and with Mrs.
Pry feeling better because of the hot flatiron and the liniment, Nan
and Bert had a chance to do some of the housework.
“How do you like keeping house, Nan?” asked Bert, as he dried
the cups and saucers.
“Well, it’s fun, but it’s a little bit lonesome,” she answered.
“I feel that way, too,” Bert said. “If Dinah and Sam were here it
wouldn’t be so lonesome. But with them gone, and daddy and
mother away, it isn’t so nice. But we’ve got to stick it out, Nan.”
“Of course we have,” she said. “I wonder what I had better cook
for lunch?”
“Bacon,” quickly answered Bert.
“Ho! Ho!” laughed his sister. “You’d have bacon three times a day,
I guess.”
“Well, it’s what fellows always have in camp, and this is like
camp,” Bert explained.
“It is, a little,” agreed Nan. “My, how the snow keeps up!”
“And the wind, too!” added Bert as a sudden gust howled around
the corner of the house, sending the hard snowflakes rattling against
the windows.
With Bert to help her, Nan tidied the rooms and set the house to
rights. Then she looked in the pantry and saw that they had enough
food for another day. She caught sight of a package of prepared
flour, out of which she had often seen Dinah make griddle cakes.
“We’ll have griddle cakes and maple syrup for lunch,” decided
Nan.
“Hurray!” cried Bert. “That’s better than bacon. But can you bake
griddle cakes, Nan?”
“Of course,” she answered.
“Let me turn them for you,” begged Bert.
“I’ll see,” was all Nan would promise.
It was shortly before noon that Nan went to the side door to look
out and see if, by any chance, the belated milkman had been along.
But the door would not open, though Nan tugged at it. Then, looking
from a side window, she saw that a big drift of snow had piled up on
the steps against the door, to which, as well as to the door jambs,
the snow had frozen.
“Oh, Bert, we’re snowed-in!” cried Nan. “We’re snowed-in, Bert!”
Bert came running from the kitchen at the sound of his sister’s
voice. At the same time, up in the attic sounded loud shouts from
Flossie and Freddie.
“Oh, what else has happened?” wailed poor Nan.
CHAPTER XIV

NAN’S BISCUITS
Bert Bobbsey at first thought something had happened to Nan
when he heard her call out. But as he came in from the kitchen and
saw her standing safely by the door, he asked:
“What’s the matter with you?”
“Nothing is the matter with me,” answered Nan. “But the door is
snowed fast. We can’t get out.”
“We can go to another door then,” said Bert, not much excited.
“Once last winter we couldn’t get the back door open because a lot
of snow had drifted against it, and we had to use the front door.
That’s nothing.”
“Well, maybe it isn’t,” Nan agreed. “But listen to that!”
She pointed upward, and Bert heard Flossie and Freddie in the
attic screaming and shouting.
“Those tykes again!” Bert cried with a laugh as he started for the
stairs. “I’ll fix ’em!”
“Oh, Bert, you’ll have to be kind to them!” pleaded Nan. “If you’re
cross and they start crying, they’ll want daddy and mother and then
we can’t do a thing with them! And there’s so much trouble now,
with Aunt Sallie in bed. Oh, dear!”
“Don’t worry,” replied Bert. “I’ll be kind to ’em, all right. I guess
Freddie is just teasing Flossie. She always yells when he teases her.
Don’t worry, Nan. Everything will be all right.”
“I hope so,” sighed Nan.
“And I’ll get a shovel and clear that snow away from the door
when I see what’s the matter with those two tykes,” went on Bert,
as he hastened upstairs. He liked to call his small brother and sister
by the funny name of “tykes,” which means a mischievous little
person.
Hurrying up to the attic, Bert found the cause of the trouble.
Flossie and Freddie, tired of playing picnic in the “woods,” had
started a circus game, each one pretending to be an animal. When
Bert got up there he saw Flossie lying on the floor with one foot and
leg thrust through the lower part of a chair. Freddie was pulling his
sister by the arms, and as her leg was caught between the chair
rounds, she could not get loose. The chair was being dragged along
with Flossie. She was crying and Freddie was shouting.
“What’s the matter? What’s the matter?” called Bert. “Stop this
kind of play!”
“This isn’t play,” Freddie explained. “We were playing, but Flossie
got her foot caught and she couldn’t get it out and I can’t pull it
out!”
“And it hurts me!” sobbed Flossie. “Oh, Bert, have I got to stay
here forever?”
“Of course not,” answered Bert. “I’ll soon have you loose. Stop
pulling, Freddie. You’ll only jam her foot in tighter. Let go!”
Freddie let go of Flossie’s arms and then, as she lay on the floor,
Bert turned her foot a little way around, so that it was crossways
with the chair rounds, instead of up and down against them, and a
moment later Flossie was free.
“Goodness!” laughed Bert, when he saw that his sister was not
hurt, though she still sobbed, “it sounded like a den of wild animals
up here!”
“I was a wild lion,” explained Freddie.
“And I was an elephant,” said Flossie. “Freddie said I must be a
bad elephant and kick the old chair over. So I kicked and my foot
went in and I couldn’t get it out again.”
“I pulled her and pulled her, but it didn’t do any good,” explained
Freddie.
“I should say not—the way you were pulling!” laughed Bert. “But I
guess you’ve had enough of playing up here. Come on downstairs.
You must have frightened Aunt Sallie out of her wits, banging
around the way you did and yelling.”
“Could we see Aunt Sallie?” asked Flossie, as she and her brother
followed Bert down the attic stairs.
“I guess so, if she isn’t asleep,” said Bert. “I’ll look in her room.”
When he did so he found the old lady sitting up in bed. She
smiled at Bert and said:
“Are there any birds up in the attic? Seems to me, Bert, I heard
birds fluttering around up there.”
The noise made by Flossie and Freddie had been very loud, so
loud that Nan had heard it away downstairs. But the deaf old lady
had thought it was only the twittering of birds. Bert wanted to laugh,
but he did not. He just said:
“No, there weren’t any birds, Aunt Sallie. It was just Flossie and
Freddie playing with a chair.”
“Oh, you say Flossie cut Freddie’s hair? She shouldn’t do that! She
might cut him or herself with the scissors. Besides, she is such a
little girl she can’t cut his hair straight. Flossie shouldn’t cut hair.
Moreover, I never knew that hair-cutting made so much noise.”
“No, no!” explained Bert. “Nobody was cutting hair. I said Flossie
and Freddie were playing with a chair!”
“Oh! Chair!” repeated Mrs. Pry. “You should speak a little more
plainly, Bert, my dear. Don’t mumble your words. But how are Flossie
and Freddie, anyhow? I haven’t seen them all day.”
“They’re out in the hall now,” explained Bert. “They’d like to see
you if you’re not too sick.”
“Bring them in, Bert. I’m feeling a little better now. Nan is a good
nurse. The hot flatiron she brought me helped the lumbago in my
back. Bring the children in.”
Flossie and Freddie looked curiously at Aunt Sallie. They had
never before seen her in bed, and as she sat up, propped against
the pillows with a blanket around her and a cap on her head, Flossie
exclaimed:
“Oh, you look just like the pictures of little Red Riding Hood’s
grandmother!”
“Do I, my dear?” asked the old lady. “Well, if I’m the
grandmother, the lumbago in my back must be the wolf. Not a real
wolf,” she added. “Just make believe, you know.”
“I know,” said Freddie. “I was playing I was a lion up in the attic.”
“And I was an elephant,” explained Flossie. “And I got my foot
caught in a chair and I couldn’t get it out!”
“Well, you’re all right now,” said the old lady, with a smile. “Be
good children now, for you’ll have to help Nan and Bert keep house
until I get better. It’s a sad time.”
“Oh, we like it,” laughed Freddie. “We can stay at home and don’t
have to go to school.”
“You say somebody lost his mule?” asked Mrs. Pry. “That’s too
bad! The mule was lost in the storm, I expect.”
Flossie and Freddie looked at each other wonderingly, and then at
Bert. They were not quite so used to the misunderstandings of the
old lady as were Bert and Nan. So Bert, before his brother and sister
should laugh at Mrs. Pry, made haste to say:
“They didn’t say anything about a mule, Aunt Sallie. Freddie said
he was glad there wasn’t any school!”
“Oh, school! Yes! Well, there’s no sense in going to school when
its such a bad storm. But I guess it will soon stop!”
However, it did not soon stop. The small Bobbsey twins went
downstairs from Mrs. Pry’s room, and the snow was still falling and
the wind was still blowing. Not that the little twins minded this—they
liked it all the more, snug and warm as they were in the house.
But Nan, getting the lunch and putting another flatiron on to heat
for Mrs. Pry’s back, shook her head more than once as she looked
out of the window.
“What’s the matter?” asked Bert as he noticed how serious his
twin sister seemed.
“I’m beginning to get worried about mother and daddy,”
answered Nan. “I don’t see why we haven’t had some word from
them—a letter or a post card.”
“I guess the mails are late on account of the storm,” Bert
remarked. “If we don’t get any to-day, and I guess we won’t, for I
haven’t heard the postman’s whistle, to-morrow I’ll go down to the
post-office and ask if there are any letters for us.”
“You can’t go if it storms this way,” Nan said.
“It will stop by to-morrow,” declared Bert.
With her brother’s help Nan managed to get up a nice little lunch
for the family, consisting of some baked potatoes, an omelet, and
some bread and preserves. She made toast for Mrs. Pry and took it
up to her with a cup of hot tea. Flossie and Freddie begged to be
allowed to help, so Nan let them carry the toast—each one had a
slice wrapped in a napkin.
“They can’t hurt the toast, even if they drop it,” Nan whispered to
Bert. But the small twins were very careful, and the toast arrived
safely in the invalid’s room.
“You are very good to me, Nan,” sighed Aunt Sallie. “I think I will
try and get around to-morrow.”
“No, you must stay in bed until your lumbago is all gone,” insisted
Nan. “I’ll bring you up another hot iron as soon as you take your
toast and tea.”
“Yes, heat is the best thing for lumbago,” said Mrs. Pry. “That and
my liniment will cure me, I expect. But my liniment is nearly gone.
And how to get more I don’t know.”
“Bert will get it for you,” offered Nan kindly.
The afternoon passed. Bert got out on the porch in his big coat
and rubber boots and cleared away some of the snow. Flossie and
Freddie wanted to go out with him, but Nan would not allow this.
She got the smaller twins into a room where they could not see Bert
at work with the snow shovel, and told them stories.
“How is it outside, Bert?” asked Nan when her brother came in,
having cleared the side door against which the big drift had blown.
“Pretty bad,” he answered. “It seems to snow harder than ever,
and the wind is blowing and it’s getting colder. I’m glad we’re inside
with a warm fire and plenty to eat.”
“That’s just the trouble,” said Nan in a low voice. “We haven’t
plenty to eat, Bert.”
“Not enough to eat—what do you mean?”
“Well, I mean we haven’t any bread. I toasted the last of it for
Mrs. Pry. There’s no bread for supper.”
“I’ll go to the store and get a loaf,” Bert offered.
“No!” cried his sister quickly. “I don’t want you to go out in the
storm. You might get lost!”
“But what’ll we do for supper?” asked Bert. “I’ve got to have
bread and butter.”
“We have plenty of butter,” explained Nan. “I’ll make a batch of
biscuits,” she added. “They’re as good as bread.”
“Better!” declared Bert. “But can you make biscuits, Nan?”
“I guess so. Mother’s told me how and I’ve watched Dinah make
them lots of times. You just mix up some flour, milk, baking powder,
water and lard and roll it out and then cut the biscuits into round
shapes and put them in a pan and bake them in the oven.”
“It sounds easy,” remarked Bert. “I’ll help you.”
When Flossie and Freddie heard what Nan was going to do, they,
also, wanted to help.
“We can’t all do it,” laughed Nan. “But you can come in the
kitchen and watch me.”
“Can I have some sugar on my bikset when it’s baked?” asked
Flossie.
“Ho! Ho!” laughed Freddie. “Listen to what she called ’em! Bikset!
Bikset!”
“That’s their name,” insisted Flossie.
“’Tisn’t!” cried Freddie. “It’s buskit! Guess I know!”
“You’re both wrong!” laughed Bert. “But no matter how you call
them, they’re going to be good when Nan bakes them. Now you two
sit down in chairs where you’ll be out of the way.”
Nan told Bert what to bring her from the pantry so she could
make the biscuits, and then, putting on an apron and rolling up her
sleeves, she began.
As she had seen Dinah do, she mixed the flour and lard together
first, kneading it with her hands.
“It’s just like making mud pies,” said Freddie.
“’Cept it isn’t brown mud—it’s white,” said Flossie.
“I wish I could squeeze ’em like that,” went on Freddie, as he saw
Nan working up the dough.
“Well, you can’t, so just you sit still!” Nan told him, with a laugh.
Remembering what her mother had told her, and what she had
seen Dinah do, Nan soon had rolled the biscuit dough out on the
floured board, and then with a shiny tin thing, she cut out little
round, flattened bits of dough, which she put in a buttered pan,
ready for the oven.
“I’ve got enough dough for two pans of biscuits,” said the little
cook. “So I’ll set this first pan down in a chair and get another pan
ready for the oven. Then they’ll both bake at the same time.”
“We’ll have lots of buskits!” said Freddie. “I’m glad, because I like
buskits!”
“And I’m going to have sugar on my bikset, ain’t I, Nan?” asked
Flossie.
“We’ll see,” said the young cook, giving all her attention to cutting
out the second batch.
Flossie and Freddie both liked to watch this part of the work, so
they left their chairs to stand beside the table. They stood on their
tiptoes, so eager were they.
“Now I’ll put these in the pan, and pop them into the oven,” said
Nan, when the last of the biscuits had been cut out. “Sit down in
your chairs, Flossie and Freddie, so you won’t be in my way when I
open the oven door.”
Flossie and Freddie went back to where they had been sitting,
and all would have been well if Flossie had taken the same chair out
of which she had slid a little while before to watch Nan. But, instead,
Flossie backed up to the wrong chair.
It was the chair on which Nan had set the first pan of biscuits,
and a moment later Flossie “plopped” herself down right on top of
the soft bits of dough!
“Oh! Oh!” yelled Freddie, but too late. “Look! Look! Flossie sat on
the buskits! Flossie’s sitting on the buskits!”
CHAPTER XV

BROKEN WIRES
Nan jumped so, because of Freddie’s shouts and Flossie’s
screams, that she almost dropped the batch of biscuits she was just
then putting into the oven. But she managed to get them in and
close the door. Then she turned and said to Freddie:
“You shouldn’t fool me that way! Oh, how you startled me!”
“He isn’t fooling you,” said Bert. “Flossie did really sit in the
biscuits!”
By this time the little girl herself had come to know that
something was wrong. She felt something soft in the chair where
she had been sitting—something soft with a hard rim around it that
had not been in it when she got up to watch Nan use the biscuit-
cutter.
“Oh! Oh!” screamed Flossie. “What is it?”
“Don’t yell so. You aren’t hurt!” said Nan.
“But the buskits are hurt!” yelled Freddie. “They’re all squashed
flat! Look at ’em!”
This was quite true—Flossie had sat down rather hard on the
biscuits and they were “squashed,” as Freddie said.
“But you can roll ’em out again, Nan,” suggested Bert. “They
aren’t spoiled. Flossie’s dress is clean—I mean it was clean before
she sat in the biscuits.”
“Is my dress—now—is it dirty?” asked Flossie, trying to turn
herself around to look at the back of her garment.
“It’s all sticky dough and flour,” stated Freddie. “You look like a
buskit yourself, Flossie!”
“Oh, dear!” sighed the little girl, and she would have burst into
tears but for Nan, who put her arms about her and kindly said:
“Never mind. Your dress will wash and the biscuits aren’t hurt
much. I can roll them out again, and I’ll give you two with sugar on.”
“Oh, all right,” agreed Flossie, and her face brightened. Then, as
Freddie said, she “squeezed back” her tears, and they all laughed at
the funny accident.
Bert picked most of the dough off Flossie’s dress while Nan took
the “squashed” biscuits from the pan, rolled the dough out again on
the moulding board, and made that batch over. Soon they were
baking in the oven with the others.
“They smell good!” declared Freddie, when his sister opened the
oven door to see how the biscuits were browning.
“They’ll taste a lot better,” laughed Bert, while Nan took Flossie
upstairs to put a clean dress on her.
In spite of the accident, Nan’s biscuits turned out very well, only a
few of them being burned, and the children ate many of them for
supper.
“Has Dinah come back?” asked Mrs. Pry, when Nan took her up a
tray with her supper on it.
“Dinah come back? No, what makes you ask that?” inquired Nan,
in surprise.
“Well, I see you have hot biscuits,” went on Mrs. Pry, with
twinkles in her eyes, “and I thought Dinah had come back to make
them.”
“No, I did it!” exclaimed Nan, and she felt very proud that Mrs.
Pry should think the biscuits as good as those which Dinah could
make.
“You made these biscuits! My, that’s wonderful!” said Aunt Sallie,
tasting one. “You are certainly a good little housekeeper.”
This pleased Nan more than ever and the lonesome feeling that
was coming over her again, as night began to fall, seemed to pass
away for a time.
After supper, or dinner, as it was called when Mr. and Mrs.
Bobbsey were at home, Bert and Nan washed and dried the dishes.
Flossie begged so hard to be allowed to help that Nan let her dry a
few.
“But you must be careful and not drop any, or they’ll break,”
cautioned Nan.
“I’ll be careful,” promised Flossie.
But alas! She was wiping a saucer when Freddie, who was playing
on the floor with his train of cars, made a sudden movement.
“Look out!” cried Flossie. “Don’t jiggle me!”
But her small brother must have “jiggled” her, or done something,
for the saucer slipped from Flossie’s hands.
Crash! It fell to the floor, breaking into half a dozen pieces.
For a moment Flossie stood there, looking at it with open mouth.
Then as she realized what had happened she burst into tears and
gasped:
“Freddie made me do it! That’s all your fault, Freddie Bobbsey. It’s
your fault!”
“Oh, it isn’t!” cried Freddie. “I wasn’t wiping the dish!”
“But you—you—now—you jiggled me!” sobbed Flossie.
“That’s what he did,” declared Bert, who had seen what had
happened.
“Never mind, my dear!” soothed Nan. “It was an old saucer
anyhow, and it was cracked.”
“Was—was it?” faltered Flossie.
“Yes, it was,” Nan replied, and this was true. It was an old dish
which had had a fall before. But this was the end of it. “Dinah often
said she was going to throw that old saucer away,” went on Nan.
“Now I’ll do it.”
It made Flossie feel better to know that she had not broken a
good dish. So she dried her tears. But Nan decided that she would
take no more chances with letting the little girl dry dishes.
“You two go in the other room with Bert and pop corn,” she
suggested, looking straight at Bert to tell him to get the small twins
out of the way. “I’ll finish the dishes,” Nan whispered to him.
“Oh, pop corn! Pop corn!” cried Freddie, dancing around. “How I
love pop corn!”
“So do I!” echoed Flossie. “I’m going to have some pop corn, ain’t
I?” she asked.
“Sure!” said Bert.
A little later, when Nan had finished the dishes, she joined Bert
and the small twins in the living room, where Bert popped corn over
the gas log. Flossie and Freddie laughed as the kernels cracked with
the heat, bursting out into queerly shaped, big, white objects.
“They look like crooked snowflakes,” was Freddie’s comment.
“But they taste better’n snowflakes,” said Flossie.
Bert wanted to melt some sugar and pour over the corn, so he
could make balls of it, but Nan said this would be too sticky. So they
melted some butter, poured that into the pan of popped corn, and
then sprinkled on some salt.
“Oh, yum! It’s good!” mumbled Bert as he filled his mouth with
the crisp corn.
“Yes,” agreed Nan, “it is. And it would be jolly fun here if only the
storm would stop.”
“It’s snowing yet,” remarked Bert as they grew quiet a moment
and listened to the flakes striking against the windows.
Though the older Bobbsey twins were a bit worried over keeping
house all by themselves, with Aunt Sallie Pry ill in bed, Flossie and
Freddie were not at all alarmed. It was a perpetual picnic for them,
and they had so much fun, playing about the room, eating pop corn
and playing they were sailors shipwrecked on a desert island, and
rushing to door or window to see the storm that Nan had hard work
to get them to go to bed.
But at last they were tucked in, and then Nan came down to sit
for a while with Bert, having first gone in to see if Mrs. Pry needed
anything.
“We’ll have to get her some more liniment in the morning, Bert,”
Nan told her brother.
“Yes, I’ll go to the store,” he agreed. “I don’t mind the snow.”
“Then you can bring in some bread,” added Nan.
“And I’ll see if there is any mail for us at the post-office,” added
her brother.
The Bobbsey twins were rather surprised the next morning when
they looked out and found that the storm had stopped. At least, the
snow had ceased falling, though a mass of gray clouds in the sky
seemed to tell of more to come.
“I can get out to the store now!” cried Bert as he quickly dressed.
“And I’ll get the mail, too!”
“I’m coming with you!” shouted Freddie.
“So am I!” echoed Flossie.
“Not much, you aren’t!” exclaimed Bert. “You’d freeze your ears
off. It’s cold out!”
He could tell this, even though he had not been out of doors, by
listening to the “squeak” of the snow as wagons were drawn along
the street in front of the house. For the snowfall had been so sudden
that few sleighs were out as yet.
“Well, I don’t want to freeze my ears,” said Freddie.
“I don’t, either,” agreed Flossie. So they no longer teased to be
allowed to go out and play.
Nan got breakfast and then gave Bert Mrs. Pry’s liniment bottle to
have filled at the drug store. She also told her brother what to bring
from the store, besides bread. Then, well wrapped up and wearing
his rubber boots, Bert started out. The snow was deep, and it was
cold, as he had said. But he did not mind even though it took his
breath to plow through it.
He stopped in the drug store first, and handed Mr. Renner the
bottle to fill with liniment.
“How’s everybody up at your house, Bert?” asked the druggist.
“We’re all right—what there is of us,” Bert answered. “My father
and mother are away, and so are Sam and Dinah. And Mrs. Pry’s in
bed with lumbago. The liniment is for her.”
“That’s too bad,” said Mr. Renner. “Winter isn’t the best time to
have lumbago—in fact, I don’t know when it is a good time to have
it. Quite a storm we had. Lot of trains stalled, wires down and all
that, I hear.”
“Trains stalled?” exclaimed Bert quickly. “When?”
“Oh, that happened yesterday when the storm was at its worst,”
the druggist said, and Bert felt easier, for he thought his mother and
father had reached Uncle Rossiter’s before they could have been
snowed-in.
“And are the wires down?” Bert asked.
“Yes, a lot of telephone and telegraph wires are broken. My
telephone is out of order and I don’t know when they’ll get it fixed.”
Bert took the liniment and went on to the post-office. There he
found a number of men gathered about the letter window. Mr.
Anderson, the postmaster, was speaking to them and Bert listened.
“There isn’t any mail in—hasn’t been for a couple of days,” said
the postmaster. “I don’t know when there will be any. A lot of mail
trains are stuck in the drifts. And the wires are down to a lot of
places so I can’t get any word as to when the mail will arrive. You’ll
just have to wait—that’s all. Blame it on the storm.”
Bert felt a sinking feeling around his heart. Still he made up his
mind he was going to ask if there was any letter from his father or
mother.
CHAPTER XVI

A GREAT CRASH
Waiting until some of the men had moved aside from the delivery
window, Bert made his way to it. Mr. Anderson knew the Bobbsey
boy, for in the summer Bert had often gone to his father’s lumber
office, and, more than once, had been allowed to go down to the
post-office for the mail.
“No letters for the lumber company to-day, Bert,” the postmaster
said, with a smile. “There were a couple yesterday, but Mr. Jones got
them.”
“I didn’t come for the office mail, Mr. Anderson,” explained the
boy. “But the postman hasn’t been at our house for two or three
days, and I thought maybe there’d be some mail here for my sister
or me.”
“I’ll look, but I don’t believe there is any, Bert,” said Mr. Anderson.
“None of the men went out yesterday, on account of the heavy
storm.”
He went back to the long table where the mail was sorted, but
when he again approached the window there were no letters in his
hands.
“Sorry, Bert, nothing for you folks,” said Mr. Anderson. “You see
everything is upset. The trains are late, and some are stuck in deep
snow up further north, I hear. And the worst of it is that a lot of
wires have been blown down so we can’t get any word. Tell your
mother the man will go out with mail as soon as any comes in.”
“I can’t tell my mother that,” stated Bert.
“Why not? Is she sick?”
“No, but Mrs. Pry is. She came to keep house for us while mother
and dad went away. Then she got sick, and Dinah and Sam went
away, and——”
“You don’t mean to tell me you Bobbsey twins are keeping house
all by yourselves!” interrupted the postmaster in astonishment.
“That’s what we’re doing,” answered Bert. “That’s why I wanted
to get a letter—to hear if my father and mother were all right.”
“Oh, I guess they’re all right, Bert,” said Mr. Anderson kindly when
he had heard the story of the trip Mr. and Mrs. Bobbsey had to take.
“It’s only that the mails are late. Probably your folks have written
you, but you won’t get the letters for a few days yet.”
“Nan and I wrote to them, telling about Sam and Dinah going
away,” explained Bert. “But I guess our letters didn’t get to them,
either.”
“No,” agreed the man at the letter window. “I don’t believe they
did. And you can’t telegraph or telephone them, either, Bert, on
account of the wires being down. But I guess things will be better in
a few days.”
“I hope so,” murmured Bert, as he turned away from the window.
Others were coming in to make inquiries. “Nan will feel sad about
not getting a letter,” thought the boy.
However, there was nothing he could do. So he left the post-office
and went to the store to get the things Nan had said were needed—
a loaf of bread, some condensed milk—since the milkman had left no
bottles—and half a dozen other things.
Now that the snow had stopped, at least for a time, the streets of
Lakeport were filling with people who had not been able to get out
of their houses during the storm. Many others besides the Bobbsey
twins needed to buy things to eat.

You might also like