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

Learning Java An Introduction to Real World Programming with Java Marc Loy pdf download

The document is a comprehensive guide to learning Java programming, covering its fundamentals, APIs, and real-world applications. It includes various editions and related resources for Java learning, along with detailed chapters on topics such as error handling, collections, and networking. The fifth edition is authored by Marc Loy, Patrick Niemeyer, and Daniel Leuck and published by O'Reilly Media.

Uploaded by

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

Learning Java An Introduction to Real World Programming with Java Marc Loy pdf download

The document is a comprehensive guide to learning Java programming, covering its fundamentals, APIs, and real-world applications. It includes various editions and related resources for Java learning, along with detailed chapters on topics such as error handling, collections, and networking. The fifth edition is authored by Marc Loy, Patrick Niemeyer, and Daniel Leuck and published by O'Reilly Media.

Uploaded by

zhyxqwdu572
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/ 66

Learning Java An Introduction to Real World

Programming with Java Marc Loy download

https://textbookfull.com/product/learning-java-an-introduction-
to-real-world-programming-with-java-marc-loy/

Download full version ebook from https://textbookfull.com


We believe these products will be a great fit for you. Click
the link to download now, or visit textbookfull.com
to discover even more!

Learning Java An Introduction to Real World Programming


with Java 5th Edition Marc Loy

https://textbookfull.com/product/learning-java-an-introduction-
to-real-world-programming-with-java-5th-edition-marc-loy/

Learning Java Beginning programming with java for


dummies First Edition John Bach

https://textbookfull.com/product/learning-java-beginning-
programming-with-java-for-dummies-first-edition-john-bach/

Introduction to Programming in Java An


Interdisciplinary Approach 2nd Edition Robert Sedgewick

https://textbookfull.com/product/introduction-to-programming-in-
java-an-interdisciplinary-approach-2nd-edition-robert-sedgewick/

Java An Introduction to Problem Solving and Programming


8th Edition Walter Savitch

https://textbookfull.com/product/java-an-introduction-to-problem-
solving-and-programming-8th-edition-walter-savitch/
Learning Network Programming with Java 1st Edition
Reese Richard M

https://textbookfull.com/product/learning-network-programming-
with-java-1st-edition-reese-richard-m/

Learning Java With Games Chong-Wei Xu

https://textbookfull.com/product/learning-java-with-games-chong-
wei-xu/

Learning Java Functional Programming 1st Edition Reese


Richard M

https://textbookfull.com/product/learning-java-functional-
programming-1st-edition-reese-richard-m/

Java Coding Problems: Become an expert Java programmer


by solving over 200 brand-new, modern, real-world
problems, 2nd edition Anghel Leonard

https://textbookfull.com/product/java-coding-problems-become-an-
expert-java-programmer-by-solving-over-200-brand-new-modern-real-
world-problems-2nd-edition-anghel-leonard/

Java Coding Problems, 2nd Edition: Become an expert


Java programmer by solving over 200 brand-new, modern,
real-world problems Anghel Leonard

https://textbookfull.com/product/java-coding-problems-2nd-
edition-become-an-expert-java-programmer-by-solving-
over-200-brand-new-modern-real-world-problems-anghel-leonard/
1. Preface
a. Who Should Read This Book
b. New Developments
i. New in This Edition (Java 11, 12, 13,
14)

c. Using This Book


d. Online Resources
e. Conventions Used in This Book
f. Using Code Examples
g. O’Reilly Online Learning
h. How to Contact Us
i. Acknowledgments

2. 1. A Modern Language

a. Enter Java

i. Java’s Origins
ii. Growing Up

b. A Virtual Machine
c. Java Compared with Other Languages
d. Safety of Design
i. Simplify, Simplify, Simplify…
ii. Type Safety and Method Binding
iii. Incremental Development
iv. Dynamic Memory Management

2
v. Error Handling
vi. Threads
vii. Scalability

e. Safety of Implementation

i. The Verifier
ii. Class Loaders
iii. Security Managers

f. Application and User-Level Security


g. A Java Road Map

i. The Past: Java 1.0–Java 11


ii. The Present: Java 14
iii. The Future
iv. Availability

3. 2. A First Application
a. Java Tools and Environment

i. Installing the JDK


ii. Installing OpenJDK on Linux
iii. Installing OpenJDK on macOS
iv. Installing OpenJDK on Windows
v. Configuring IntelliJ IDEA and
Creating a Project
vi. Running the Project
vii. Grabbing the Learning Java Examples
b. HelloJava

3
i. Classes
ii. The main() Method
iii. Classes and Objects
iv. Variables and Class Types
v. HelloComponent
vi. Inheritance
vii. The JComponent Class
viii. Relationships and Finger-Pointing
ix. Package and Imports
x. The paintComponent() Method
c. HelloJava2: The Sequel

i. Instance Variables
ii. Constructors
iii. Events
iv. The repaint() Method
v. Interfaces

d. Goodbye and Hello Again


4. 3. Tools of the Trade

a. JDK Environment
b. The Java VM
c. Running Java Applications
i. System Properties

d. The Classpath
i. javap

4
ii. Modules
e. The Java Compiler
f. Trying Java
g. JAR Files

i. File Compression
ii. The jar Utility
iii. The pack200 Utility

h. Building Up

5. 4. The Java Language

a. Text Encoding
b. Comments

i. Javadoc Comments

c. Variables and Constants


d. Types
i. Primitive Types
ii. Reference Types
iii. Inferring Types
iv. Passing References
v. A Word About Strings
e. Statements and Expressions

i. Statements
ii. Expressions

f. Arrays
i. Array Types

5
ii. Array Creation and Initialization
iii. Using Arrays
iv. Anonymous Arrays
v. Multidimensional Arrays
g. Types and Classes and Arrays, Oh My!

6. 5. Objects in Java

a. Classes

i. Declaring and Instantiating Classes


ii. Accessing Fields and Methods
iii. Static Members

b. Methods

i. Local Variables
ii. Shadowing
iii. Static Methods
iv. Initializing Local Variables
v. Argument Passing and References
vi. Wrappers for Primitive Types
vii. Method Overloading

c. Object Creation

i. Constructors
ii. Working with Overloaded
Constructors

d. Object Destruction
i. Garbage Collection

6
e. Packages
i. Importing Classes
ii. Custom Packages
iii. Member Visibility and Access
iv. Compiling with Packages
f. Advanced Class Design

i. Subclassing and Inheritance


ii. Interfaces
iii. Inner Classes
iv. Anonymous Inner Classes
g. Organizing Content and Planning for Failure

7. 6. Error Handling and Logging

a. Exceptions

i. Exceptions and Error Classes


ii. Exception Handling
iii. Bubbling Up
iv. Stack Traces
v. Checked and Unchecked Exceptions
vi. Throwing Exceptions
vii. try Creep
viii. The finally Clause
ix. try with Resources
x. Performance Issues

b. Assertions

7
i. Enabling and Disabling Assertions
ii. Using Assertions
c. The Logging API

i. Overview
ii. Logging Levels
iii. A Simple Example
iv. Logging Setup Properties
v. The Logger
vi. Performance
d. Real-World Exceptions
8. 7. Collections and Generics

a. Collections
i. The Collection Interface
ii. Collection Types
iii. The Map Interface
b. Type Limitations

i. Containers: Building a Better


Mousetrap
ii. Can Containers Be Fixed?

c. Enter Generics
i. Talking About Types
d. “There Is No Spoon”

i. Erasure
ii. Raw Types

8
e. Parameterized Type Relationships

i. Why Isn’t a List<Date> a


List<Object>?
f. Casts
i. Converting Between Collections and
Arrays
ii. Iterator
g. A Closer Look: The sort() Method
h. Application: Trees on the Field
i. Conclusion

9. 8. Text and Core Utilities


a. Strings
i. Constructing Strings
ii. Strings from Things
iii. Comparing Strings
iv. Searching
v. String Method Summary
b. Things from Strings

i. Parsing Primitive Numbers


ii. Tokenizing Text
c. Regular Expressions

i. Regex Notation
ii. The java.util.regex API
d. Math Utilities

9
i. The java.lang.Math Class
ii. Big/Precise Numbers

e. Dates and Times


i. Local Dates and Times
ii. Comparing and Manipulating Dates
and Times
iii. Time Zones
iv. Parsing and Formatting Dates and
Times
v. Parsing Errors
vi. Timestamps

f. Other Useful Utilities


10. 9. Threads
a. Introducing Threads

i. The Thread Class and the Runnable


Interface
ii. Controlling Threads
iii. Death of a Thread
b. Synchronization
i. Serializing Access to Methods
ii. Accessing Class and Instance
Variables from Multiple Threads
c. Scheduling and Priority

i. Thread State
ii. Time-Slicing

10
iii. Priorities
iv. Yielding
d. Thread Performance

i. The Cost of Synchronization


ii. Thread Resource Consumption

e. Concurrency Utilities
11. 10. Desktop Applications
a. Buttons and Sliders and Text Fields, Oh My!

i. Component Hierarchies
ii. Model View Controller Architecture
iii. Labels and Buttons
iv. Text Components
v. Other Components

b. Containers and Layouts


i. Frames and Windows
ii. JPanel
iii. Layout Managers
c. Events

i. Mouse Events
ii. Action Events
iii. Change Events
iv. Other Events
d. Modals and Pop Ups
i. Message Dialogs

11
ii. Confirmation Dialogs
iii. Input Dialogs
e. Threading Considerations

i. SwingUtilities and Component


Updates
ii. Timers
f. Next Steps

i. Menus
ii. Preferences
iii. Custom Components and Java2D
iv. JavaFX
g. User Interface and User Experience

12. 11. Networking and I/O


a. Streams
i. Basic I/O
ii. Character Streams
iii. Stream Wrappers
iv. The java.io.File Class
v. File Streams
vi. RandomAccessFile

b. The NIO File API


i. FileSystem and Path
ii. NIO File Operations
c. The NIO Package

12
i. Asynchronous I/O
ii. Performance
iii. Mapped and Locked Files
iv. Channels
v. Buffers
vi. Character Encoders and Decoders
vii. FileChannel
d. Network Programming
e. Sockets

i. Clients and Servers


ii. The DateAtHost Client
iii. A Distributed Game

f. More to Explore
13. 12. Programming for the Web

a. Uniform Resource Locators


b. The URL Class
i. Stream Data
ii. Getting the Content as an Object
iii. Managing Connections
iv. Handlers in Practice
v. Useful Handler Frameworks

c. Talking to Web Applications

i. Using the GET Method


ii. Using the POST Method

13
iii. The HttpURLConnection
iv. SSL and Secure Web Communications
d. Java Web Applications

i. The Servlet Life Cycle


ii. Servlets
iii. The HelloClient Servlet
iv. The Servlet Response
v. Servlet Parameters
vi. The ShowParameters Servlet
vii. User Session Management
viii. The ShowSession Servlet

e. Servlet Containers

i. Configuration with web.xml and


Annotations
ii. URL Pattern Mappings
iii. Deploying HelloClient
f. The World Wide Web Is, Well, Wide

14. 13. Expanding Java

a. Java Releases
i. JCP and JSRs

b. Lambda Expressions

i. Retrofitting Your Code


c. Expanding Java Beyond the Core
d. Final Wrap-Up and Next Steps

14
15. A. Code Examples and IntelliJ IDEA

a. Grabbing the Main Code Examples


b. Installing IntelliJ IDEA

i. Installing on Linux
ii. Installing on a macOS
iii. Installing on Windows

c. Importing the Examples


d. Running the Examples
e. Grabbing the Web Code Examples
f. Working with Servlets
16. Glossary
17. Index

15
Learning Java
FIFTH EDITION

An Introduction to Real-World Programming with


Java

Marc Loy, Patrick Niemeyer, and Daniel Leuck

16
Learning Java

by Marc Loy, Patrick Niemeyer, and Daniel Leuck

Copyright © 2020 Marc Loy, Patrick Niemeyer, Daniel Leuck. All


rights reserved.

Printed in the United States of America.

Published by O’Reilly Media, Inc., 1005 Gravenstein Highway


North, Sebastopol, CA 95472.

O’Reilly books may be purchased for educational, business, or sales


promotional use. Online editions are also available for most titles
(http://oreilly.com). For more information, contact our
corporate/institutional sales department: 800-998-9938 or
[email protected].

Acquisitions Editor: Suzanne McQuade

Developmental Editor: Amelia Blevins

Production Editor: Beth Kelly

Copyeditor: Sonia Saruba

Proofreader: Christina Edwards

Indexer: Angela Howard

Interior Designer: David Futato

Cover Designer: Karen Montgomery

17
Illustrator: Rebecca Demarest

May 2000: First Edition


July 2002: Second Edition
May 2005: Third Edition
June 2013: Fourth Edition
March 2020: Fifth Edition

Revision History for the Fifth Edition


2020-03-27: First Release

See http://oreilly.com/catalog/errata.csp?isbn=9781492056270 for


release details.

The O’Reilly logo is a registered trademark of O’Reilly Media, Inc.


Learning Java, the cover image, and related trade dress are
trademarks of O’Reilly Media, Inc.

While the publisher and the authors have used good faith efforts to
ensure that the information and instructions contained in this work
are accurate, the publisher and the authors disclaim all responsibility
for errors or omissions, including without limitation responsibility
for damages resulting from the use of or reliance on this work. Use
of the information and instructions contained in this work is at your
own risk. If any code samples or other technology this work contains
or describes is subject to open source licenses or the intellectual
property rights of others, it is your responsibility to ensure that your
use thereof complies with such licenses and/or rights.

978-1-492-05627-0

[LSI]

18
Preface

This book is about the Java programming language and


environment. Whether you are a software developer or just someone
who uses the internet in your daily life, you’ve undoubtedly heard
about Java. Its introduction was one of the most exciting
developments in the history of the web, and Java applications have
powered much of the growth of business on the internet. Java is,
arguably, the most popular programming language in the world,
used by millions of developers on almost every kind of computer
imaginable. Java has surpassed languages such as C++ and Visual
Basic in terms of developer demand and has become the de facto
language for certain kinds of development—especially for web-
based services. Most universities are now using Java in their
introductory courses alongside the other important modern
languages. Perhaps you are using this text in one of your classes
right now!

This book gives you a thorough grounding in Java fundamentals and


APIs. Learning Java, Fifth Edition, attempts to live up to its name
by mapping out the Java language and its class libraries,
programming techniques, and idioms. We’ll dig deep into interesting
areas and at least scratch the surface of other popular topics. Other
titles from O’Reilly pick up where we leave off and provide more
comprehensive information on specific areas and applications of
Java.

Whenever possible, we provide compelling, realistic, and fun

19
examples and avoid merely cataloging features. The examples are
simple, but hint at what can be done. We won’t be developing the
next great “killer app” in these pages, but we hope to give you a
starting point for many hours of experimentation and inspired
tinkering that will lead you to develop one yourself.

Who Should Read This Book


This book is for computer professionals, students, technical people,
and Finnish hackers. It’s for everyone who has a need for hands-on
experience with the Java language with an eye toward building real
applications. This book could also be considered a crash course in
object-oriented programming, networking, and user interfaces. As
you learn about Java, you’ll also learn a powerful and practical
approach to software development, beginning with a deep
understanding of the fundamentals of Java and its APIs.

Superficially, Java looks like C or C++, so you’ll have a tiny


headstart in using this book if you have some experience with one of
these languages. If you do not, don’t worry. Don’t make too much of
the syntactic similarities between Java and C or C++. In many
respects, Java acts like more dynamic languages such as Smalltalk
and Lisp. Knowledge of another object-oriented programming
language should certainly help, although you may have to change
some ideas and unlearn a few habits. Java is considerably simpler
than languages such as C++ and Smalltalk. If you learn well from
concise examples and personal experimentation, we think you’ll like
this book.

The last part of this book branches out to discuss Java in the context
of web applications, web services, and request processing, so you

20
should be familiar with the basic ideas behind web browsers,
servers, and documents.

New Developments
This edition of Learning Java is actually the seventh edition—
updated and retitled—of our original, popular Exploring Java. With
each edition, we’ve taken great care not only to add new material
covering additional features, but to thoroughly revise and update the
existing content to synthesize the coverage and add years of real-
world perspective and experience to these pages.

One noticeable change in recent editions is that we’ve de-


emphasized the use of applets, reflecting their diminished role in
recent years in creating interactive web pages. In contrast, we’ve
greatly expanded our coverage of Java web applications and web
services, which are now mature technologies.

We cover all of the important features of the latest “long-term


support” release of Java, officially called Java Standard Edition (SE)
11, OpenJDK 11, but we also add in a few details from the “feature”
releases of Java 12, Java 13, and Java 14. Sun Microsystems (Java’s
keeper before Oracle) has changed the naming scheme many times
over the years. Sun coined the term Java 2 to cover the major new
features introduced in Java version 1.2 and dropped the term JDK in
favor of SDK. With the sixth release, Sun skipped from Java version
1.4 to Java 5.0, but reprieved the term JDK and kept its numbering
convention there. After that, we had Java 6, Java 7, and so on, and
now we are at Java 14.

This release of Java reflects a mature language with occasional

21
syntactic changes and updates to APIs and libraries. We’ve tried to
capture these new features and update every example in this book to
reflect not only the current Java practice, but style as well.

New in This Edition (Java 11, 12, 13, 14)


This edition of the book continues our tradition of rework to be as
complete and up-to-date as possible. It incorporates changes from
both the Java 11—again, the long-term support version—and Java
12, 13, and 14 feature releases. (More on the specifics of the Java
features included and excluded in recent releases in Chapter 13.)
New topics in this edition include:

New language features, including type inference in generics


and improved exception handling and automatic resource
management syntax
New interactive playground, jshell, for trying out code
snippets
The proposed switch expression
Basic lambda expressions
Updated examples and analysis throughout the book

Using This Book


This book is organized roughly as follows:

Chapters 1 and 2 provide a basic introduction to Java


concepts and a tutorial to give you a jump-start on Java
programming.
Chapter 3 discusses fundamental tools for developing with
Java (the compiler, the interpreter, jshell, and the JAR
file package).

22
Chapters 4 and 5 introduce programming fundamentals,
then describe the Java language itself, beginning with the
basic syntax and then covering classes and objects,
exceptions, arrays, enumerations, annotations, and much
more.
Chapter 6 covers exceptions, errors, and the logging
facilities native to Java.
Chapter 7 covers collections alongside generics and
parameterized types in Java.
Chapter 8 covers text processing, formatting, scanning,
string utilities, and much of the core API utilities.
Chapter 9 covers the language’s built-in thread facilities.
Chapter 10 covers the basics of graphical user interface
(GUI) development with Swing.
Chapter 11 covers Java I/O, streams, files, sockets,
networking, and the NIO package.
Chapter 12 covers web applications using servlets, servlet
filters, and WAR files, as well as web services.
Chapter 13 introduces the Java Community Process and
highlights how to track future changes to Java while
helping you retrofit existing code with new features, such as
the lambda expressions introduced in Java 8.

If you’re like us, you don’t read books from front to back. If you’re
really like us, you usually don’t read the preface at all. However, on
the off chance that you will see this in time, here are a few
suggestions:

If you are already a programmer and just need to learn Java


in the next five minutes, you are probably looking for the
examples. You might want to start by glancing at the
tutorial in Chapter 2. If that doesn’t float your boat, you

23
should at least look at the information in Chapter 3, which
explains how to use the compiler and interpreter. This
should get you started.
Chapters 11 and 12 are the places to head if you are
interested in writing network or web-based applications and
services. Networking remains one of the more interesting
and important parts of Java.
Chapter 10 discusses Java’s graphics features and
component architecture. You should read this if you are
interested in writing desktop graphical Java applications.
Chapter 13 discusses how to stay on top of changes to the
Java language itself, regardless of your particular focus.

Online Resources
There are many online sources for information about Java.

Oracle’s official website for Java topics is https://oreil.ly/Lo8QZ;


look here for the software, updates, and Java releases. This is where
you’ll find the reference implementation of the JDK, which includes
the compiler, the interpreter, and other tools.

Oracle also maintains the OpenJDK site. This is the primary open
source version of Java and the associated tools. We’ll be using the
OpenJDK for all the examples in this book.

You should also visit O’Reilly’s site at http://oreilly.com/. There


you’ll find information about other O’Reilly books for both Java and
a growing array of other topics. You should also check out the
online learning and conference options—O’Reilly is a real champion
for education in all its forms.

24
And of course, you can check the home page for Learning Java!

Conventions Used in This Book


The font conventions used in this book are quite simple.

Italic is used for:

Pathnames, filenames, and program names


Internet addresses, such as domain names and URLs
New terms where they are defined
Program names, compilers, interpreters, utilities, and
commands
Threads

Constant width is used for:

Anything that might appear in a Java program, including


method names, variable names, and class names
Tags that might appear in an HTML or XML document
Keywords, objects, and environment variables

Constant width bold is used for:

Text that is typed by the user on the command line or in a


dialog

Constant width italic is used for:

Replaceable items in code

In the main body of text, we always use a pair of empty parentheses


after a method name to distinguish methods from variables and other

25
creatures.

In the Java source listings, we follow the coding conventions most


frequently used in the Java community. Class names begin with
capital letters; variable and method names begin with lowercase. All
the letters in the names of constants are capitalized. We don’t use
underscores to separate words in a long name; following common
practice, we capitalize individual words (after the first) and run the
words together. For example: thisIsAVariable,
thisIsAMethod(), ThisIsAClass, and
THIS_IS_A_CONSTANT. Also, note that we differentiate between
static and nonstatic methods when we refer to them. Unlike some
books, we never write Foo.bar() to mean the bar() method of
Foo unless bar() is a static method (paralleling the Java syntax in
that case).

Using Code Examples


If you have a technical question or a problem using the code
examples, please send email to [email protected].

This book is here to help you get your job done. In general, if
example code is offered with this book, you may use it in your
programs and documentation. You do not need to contact us for
permission unless you’re reproducing a significant portion of the
code. For example, writing a program that uses several chunks of
code from this book does not require permission. Selling or
distributing examples from O’Reilly books does require permission.
Answering a question by citing this book and quoting example code
does not require permission. Incorporating a significant amount of
example code from this book into your product’s documentation

26
does require permission.

We appreciate, but generally do not require, attribution. An


attribution usually includes the title, author, publisher, and ISBN.
For example: “Learning Java, Fifth Edition, by Marc Loy, Patrick
Niemeyer, and Daniel Leuck (O’Reilly). Copyright 2020 Marc Loy,
Patrick Niemeyer, and Daniel Leuck, 978-1-492-05627-0.”

If you feel your use of code examples falls outside fair use or the
permission given above, feel free to contact us at
[email protected].

O’Reilly Online Learning

NOTE
For more than 40 years, O’Reilly Media has provided technology
and business training, knowledge, and insight to help companies
succeed.

Our unique network of experts and innovators share their knowledge


and expertise through books, articles, and our online learning
platform. O’Reilly’s online learning platform gives you on-demand
access to live training courses, in-depth learning paths, interactive
coding environments, and a vast collection of text and video from
O’Reilly and 200+ other publishers. For more information, please
visit http://oreilly.com.

How to Contact Us

27
Please address comments and questions concerning this book to the
publisher:

O’Reilly Media, Inc.

1005 Gravenstein Highway North

Sebastopol, CA 95472

800-998-9938 (in the United States or Canada)

707-829-0515 (international or local)

707-829-0104 (fax)

We have a web page for this book where we list errata and any
additional information. You can access this page at
https://oreil.ly/Java_5e.

The example code can be found separately on GitHub. There are two
repositories for this book: the main examples and the web examples.
More details on accessing and working the examples is provided in
Appendix A.

Email [email protected] to comment or ask technical


questions about this book.

For more information about our books, courses, and news, see our
website at http://www.oreilly.com.

Find us on Facebook: http://facebook.com/oreilly

Follow us on Twitter: http://twitter.com/oreillymedia

28
Watch us on YouTube: http://www.youtube.com/oreillymedia

Acknowledgments
Many people have contributed to putting this book together, both in
its Exploring Java incarnation and in its current form as Learning
Java. Foremost, we would like to thank Tim O’Reilly for giving us
the opportunity to write this book. Thanks to Mike Loukides, the
series editor, whose patience and experience continue to guide us.
Other folks from O’Reilly, including Amelia Blevins, Zan
McQuade, Corbin Collins, and Jessica Haberman, have provided
consistent wisdom and encouragement. We could not have asked for
a more skillful or responsive team of people with whom to work.

The original version of the glossary came from David Flanagan’s


book Java in a Nutshell (O’Reilly). We also borrowed several class
hierarchy diagrams from David’s book. These diagrams were based
on similar diagrams by Charles L. Perkins.

Warm thanks to Ron Becker for sound advice and interesting ideas
as seen from the perspective of a layman well removed from the
programming world. Thanks also to James Elliott and Dan Leuck for
their excellent and timely feedback on the technical content of this
edition. As with so many things in the programming world, extra
eyes are indispensible, and we are lucky to have had such attentive
pairs in our corner.

29
Other documents randomly have
different content
Enter Valentine.

How now! what news from her?

Val. So please my lord, I might not be admitted;


25
But from her handmaid do return this answer:
The element itself, till seven years' heat,
Shall not behold her face at ample view;
But, like a cloistress, she will veiled walk
And water once a day her chamber round
30
With eye-offending brine: all this to season
A brother's dead love, which she would keep fresh
And lasting in her sad remembrance.

Duke. O, she that hath a heart of that fine frame


To pay this debt of love but to a brother,
35
How will she love, when the rich golden shaft
Hath kill'd the flock of all affections else
That live in her; when liver, brain and heart,
These sovereign thrones, are all supplied, and fill'd
Her sweet perfections with one self king!
40
Away before me to sweet beds of flowers:
Love-thoughts lie rich when canopied with bowers. [Exeunt.

LINENOTES:
Twelfth Night] Twelfe Night F1.
Musicians ...] Musick ... Capell. om. Ff.
[2, 3] surfeiting, The appetite may] surfeiting The app'tite, Love may
Warburton.
[5] sound] Ff. wind Rowe (ed. 1). south Pope. sou' wind Anon. conj. scent
Dent MS. apud Halliwell. sough Anon. conj.
[11] sea,] Rowe (ed. 2). sea. Ff. sea; Rowe (ed. 1).
[14] is fancy] in fancy Theobald (Warburton).
[15] That it alone is] And thou all o'er art Hanmer.
high] hight Warburton.
[16] Curio] Curia F4.
[19] mine] my Pope (ed. 2).
[20] Methought ... pestilence!] (Methought ... pestilence) Capell.
[23] E'er] Rowe. Ere F1 F2 F4. E're F3.
Enter V.] Ff (after her).
[26] years' heat] Harness. yeares heate F1 F2. yeares heat F3. years heat
F4. years hence Rowe (ed. 2). See note (ii).
[29] chamber] F1. chambers F2 F3 F4. chamber's Capell.
[32] remembrance] remembrance still Pope, rememberance Capell conj.
MS.
[38] These] Three Hanmer (Warburton).
[38, 39] are ... fill'd Her ... perfections] are ... fill'd, (O sweet perfection!)
Warburton conj. are ... filled, Her ... perfections, Pope. are ... fill'd, (Her
sweet perfection) Capell. her ... perfections Are ... fill'd Collier conj.
[39] self] selfe F1. selfe same F2. self same F3. self-same F4.
[41] Love-thoughts] F1 F2 F3. Love thoughts F4.

Scene II. The sea-coast.


Enter Viola, a Captain, and Sailors.

Vio. What country, friends, is this?

Cap. This is Illyria, lady.

Vio. And what should I do in Illyria?


My brother he is in Elysium.
5
Perchance he is not drown'd: what think you, sailors?

Cap. It is perchance that you yourself were saved.

Vio. O my poor brother! and so perchance may he be.

Cap. True, madam: and, to comfort you with chance,


Assure yourself, after our ship did split,
10
When you and those poor number saved with you
Hung on our driving boat, I saw your brother,
Most provident in peril, bind himself,
Courage and hope both teaching him the practice,
To a strong mast that lived upon the sea;
15
Where, like Arion on the dolphin's back,
I saw him hold acquaintance with the waves
So long as I could see.

Vio. For saying so, there's gold:


Mine own escape unfoldeth to my hope,
20
Whereto thy speech serves for authority,
The like of him. Know'st thou this country?

Cap. Ay, madam, well; for I was bred and born


Not three hours' travel from this very place.
Vio. Who governs here?

25
Cap. A noble Duke, in nature as in name.

Vio. What is his name?

Cap. Orsino.

Vio. Orsino! I have heard my father name him:


He was a bachelor then.

30
Cap. And so is now, or was so very late;
For but a month ago I went from hence,
And then 'twas fresh in murmur,—as, you know,
What great ones do the less will prattle of,—
That he did seek the love of fair Olivia.

35
Vio. What's she?

Cap. A virtuous maid, the daughter of a count


That died some twelvemonth since; then leaving her
In the protection of his son, her brother,
Who shortly also died: for whose dear love,
40
They say, she hath abjured the company
And sight of men.

Vio. O that I served that lady,


And might not be delivered to the world,
Till I had made mine own occasion mellow,
What my estate is!

Cap. That were hard to compass;


45
Because she will admit no kind of suit,
No, not the Duke's.

Vio. There is a fair behaviour in thee, captain;


And though that nature with a beauteous wall
Doth oft close in pollution, yet of thee
50
I will believe thou hast a mind that suits
With this thy fair and outward character.
I prithee, and I'll pay thee bounteously,
Conceal me what I am, and be my aid
For such disguise as haply shall become
55
The form of my intent. I'll serve this Duke:
Thou shalt present me as an eunuch to him:
It may be worth thy pains; for I can sing,
And speak to him in many sorts of music,
That will allow me very worth his service.
60
What else may hap to time I will commit;
Only shape thou thy silence to my wit.

Cap. Be you his eunuch, and your mute I'll be:


When my tongue blabs, then let mine eyes not see.

Vio. I thank thee: lead me on. [Exeunt.

LINENOTES:
Scene II.: The sea-coast] Capell. The street. Rowe.
[2] This is] om. Pope.
[7] and so] so Pope.
[10] those] that Rowe (ed. 2). this Capell. the Anon. conj.
[11] our] your Rowe.
driving] droving F3 F4.
[15] Arion] Pope. Orion Ff.
[18] For ... gold] There's gold for saying so Pope.
[21] Know'st] And knowest Hanmer.
[24-27] Who ... Orsino] As two lines in Hanmer, ending nature ... Orsino.
[25] in name] in his name Hanmer.
[29-35] He was ... she?] As six lines in Steevens (1793), ending, now, ...
month ... fresh ... do, ... seek ... she?
[37] twelvemonth] twelve months Rowe.
[39] love] loss S. Walker conj.
[40] hath] F1. had F2 F3 F4.
[40, 41] company And sight] Hanmer. sight And company Ff.
[42] And] And't Hanmer.
delivered] deliver'd Rowe.
[43] mellow,] Hanmer. mellow Ff. fellow Anon. conj.
[50] will] weil S. Walker conj.

Scene III. Olivia's house.


Enter Sir Toby Belch and Maria.

Sir To. What a plague means my niece, to take the death


of her brother thus? I am sure care's an enemy to life.

Mar. By my troth, Sir Toby, you must come in earlier


o' nights: your cousin, my lady, takes great exceptions to
5
your ill hours.

Sir Toby. Why, let her except, before excepted.

Mar. Ay, but you must confine yourself within the


modest limits of order.

Sir To. Confine! I'll confine myself no finer than I


10
am: these clothes are good enough to drink in; and so be
these boots too: an they be not, let them hang themselves
in their own straps.

Mar. That quaffing and drinking will undo you: I


heard my lady talk of it yesterday; and of a foolish knight
15
that you brought in one night here to be her wooer.

Sir To. Who, Sir Andrew Aguecheek?

Mar. Ay, he.

Sir To. He's as tall a man as any's in Illyria.

Mar. What's that to the purpose?

20
Sir To. Why, he has three thousand ducats a year.
Mar. Ay, but he'll have but a year in all these ducats:
he's a very fool and a prodigal.

Sir To. Fie, that you'll say so! he plays o' the viol-de-
gamboys,
and speaks three or four languages word for word
25
without book, and hath all the good gifts of nature.

Mar. He hath indeed, almost natural: for besides


that he's a fool, he's a great quarreller; and but that he
hath the gift of a coward to allay the gust he hath in
quarrelling,
'tis thought among the prudent he would quickly
30
have the gift of a grave.

Sir To. By this hand, they are scoundrels and substractors


that say so of him. Who are they?

Mar. They that add, moreover, he's drunk nightly in


your company.

35
Sir To. With drinking healths to my niece: I 'll drink
to her as long as there is a passage in my throat and drink
in Illyria: he's a coward and a coystrill that will not drink
to my niece till his brains turn o' the toe like a parish-top.
What, wench! Castiliano vulgo; for here comes Sir Andrew
40
Agueface.

Enter Sir Andrew Aguecheek.

Sir And. Sir Toby Belch! how now, Sir Toby Belch!

Sir To. Sweet Sir Andrew!


Sir And. Bless you, fair shrew.

Mar. And you too, sir.

45
Sir To. Accost, Sir Andrew, accost.

Sir And. What's that?

Sir To. My niece's chambermaid.

Sir And. Good Mistress Accost, I desire better


acquaintance.

50
Mar. My name is Mary, sir.

Sir And. Good Mistress Mary Accost,—

Sir To. You mistake, knight: 'accost' is front her, board


her, woo her, assail her.

Sir And. By my troth, I would not undertake her in


55
this company. Is that the meaning of 'accost'?

Mar. Fare you well, gentlemen.

Sir To. An thou let part so, Sir Andrew, would thou
mightst never draw sword again.

Sir And. An you part so, mistress, I would I might


60
never draw sword again. Fair lady, do you think you have
fools in hand?

Mar. Sir, I have not you by the hand.


Sir And. Marry, but you shall have; and here's my
hand.

65
Mar. Now, sir, 'thought is free': I pray you, bring your
hand to the buttery-bar and let it drink.

Sir And. Wherefore, sweet-heart? what's your metaphor?

Mar. It's dry, sir.

70
Sir And. Why, I think so: I am not such an ass but I
can keep my hand dry. But what's your jest?

Mar. A dry jest, sir.

Sir And. Are you full of them?

Mar. Ay, sir, I have them at my fingers' ends: marry,


75
now I let go your hand, I am barren. [Exit.

Sir To. O knight, thou lackest a cup of canary: when


did I see thee so put down?

Sir And. Never in your life, I think; unless you see


canary put me down. Methinks sometimes I have no more
80
wit than a Christian or an ordinary man has: but I am a
great eater of beef and I believe that does harm to my wit.

Sir To. No question.

Sir And. An I thought that, I'ld forswear it. I'll ride


home to-morrow, Sir Toby.

85
Sir To. Pourquoi, my dear knight?

Sir And. What is 'pourquoi'? do or not do? I would


I had bestowed that time in the tongues that I have in
fencing, dancing and bear-baiting: O, had I but followed
the arts!

90
Sir To. Then hadst thou had an excellent head of
hair.

Sir And. Why, would that have mended my hair?

Sir To. Past question; for thou seest it will not curl
by nature.

95
Sir And. But it becomes me well enough, does't not?

Sir To. Excellent; it hangs like flax on a distaff; and


I hope to see a housewife take thee between her legs and
spin it off.

Sir And. Faith, I'll home to-morrow, Sir Toby: your


100
niece will not be seen; or if she be, it's four to one she'll
none of me: the count himself here hard by woos her.

Sir To. She'll none o' the count: she'll not match
above her degree, neither in estate, years, nor wit; I have
heard her swear't. Tut, there's life in't, man.

105
Sir And. I'll stay a month longer. I am a fellow o'
the strangest mind i' the world; I delight in masques and
revels sometimes altogether.

Sir To Art thou good at these kickshawses knight?


Sir To. Art thou good at these kickshawses, knight?

Sir And. As any man in Illyria, whatsoever he be,


110
under the degree of my betters; and yet I will not compare
with an old man.

Sir To. What is thy excellence in a galliard, knight?

Sir And. Faith, I can cut a caper.

Sir To. And I can cut the mutton to't.

115
Sir And. And I think I have the back-trick simply as
strong as any man in Illyria.

Sir To. Wherefore are these things hid? wherefore


have these gifts a curtain before 'em? are they like to take
dust, like Mistress Mall's picture? why dost thou not go to
120
church in a galliard and come home in a coranto? My
very walk should be a jig; I would not so much as make
water but in a sink-a-pace. What dost thou mean? Is it
a world to hide virtues in? I did think, by the excellent
constitution of thy leg, it was formed under the star of a
125
galliard.

Sir And. Ay, 'tis strong, and it does indifferent well


in a flame-coloured stock. Shall we set about some revels?

Sir To. What shall we do else? were we not born


under Taurus?

130
Sir And. Taurus! That's sides and heart.

Si T N i it i l d thi h L t th
Sir To. No, sir; it is legs and thighs. Let me see thee
caper: ha! higher: ha, ha! excellent! [Exeunt.

LINENOTES:
Scene III.: Olivia's house.] Rowe.
[4] o'] Capell. a Ff.
cousin] neice Rowe (ed. 2).
[6] except,] Ff. except Hanmer.
before] as before Rann (Farmer conj.).
[11] an] Theobald. and Ff. if Pope.
[18] any's] any Pope.
[20] has] F3 F4. ha's F1 F2.
[23, 24] viol-de-gamboys] viol-de-gambo Rowe.
[26] indeed, almost] indeed all, most Collier (Upton conj.).
[28] gust] gift Meredith conj.
[31] substractors] subtractors Warburton.
[33] that add, moreover,] add, moreover, that Anon. conj.
[36] there is] there's Pope (ed. 2).
[37] coystrill] coystril F4. kestrel Hanmer.
[39] vulgo] volto Hanmer (Warburton). volgo Johnson.
[40] Agueface] Auge-cheek Theobald.
[41] Scene iv. Pope.
Enter ...] Enter Sir Andrew. Ff.
[48] Sir And.] Ma. F1.
acquaintance] acquaintance— S. Walker conj. See note (iii).
[51] Mary Accost] Rowe. Mary, accost Ff.
[52, 53] board her] bourd her Whalley conj. bourd with her Steevens conj.
[57] An thou let part] Capell. And thou let part F1 F2. And thou let her
part F3 F4. If thou let her part Pope. An thou let her part Theobald.
[59] An] Theobald. And Ff. If Pope.
[65] Now] Nay S. Walker conj.
[74] Fingers'] fingers F1 F2. finger F3 F4. finger's Steevens.
[75] [Exit.] Exit Maria. Ff.
[79] put me] F1. put F2 F3 F4.
[80] has] F4. ha's F1 F2 F3.
[83] An] Theobald. And Ff. If Pope.
[85] Pourquoi] Pur-quoy Ff.
[93, 94] curl by] Theobald. cool my Ff.
[95] me] we F1.
[101, 102] count] Ff. Duke Rowe.
[104] swear't] sweare t F1. sweare F2. swear F3 F4. swear it Theobald.
[108] kickshawses] F3. kicke-chawses F1 F2. kick-shaws F4.
[111] an old man] a nobleman Theobald conj.
[112] excellence] excellence? Mason conj.
[115] [Dances fantastically. Collier (Collier MS.).
[120] coranto] Rowe (ed. 2). carranto Ff.
[122] sink-a-pace] cinque-pace Hanmer.
[123] think] not think Rowe.
[127] in a] in Warburton.
flame-coloured] Rowe (ed. 2). dam'd colour'd Ff. damask-coloured Knight.
dun-colour'd Collier MS. damson-coloured Phelps conj. dove-coloured
Anon. conj.
stock] stocke F1 F2. stocken F3 F4. stocking Pope.
set] Rowe (ed. 2). sit Ff.
[130] That's] F3 F4. That F1 F2.
[132] [Sir A. dances again. Collier (Collier MS.).

Scene IV. The Duke's palace.


Enter Valentine, and Viola in man's attire.

Val. If the Duke continue these favours towards you,


Cesario, you are like to be much advanced: he hath known
you but three days, and already you are no stranger.

Vio. You either fear his humour or my negligence,


5
that you call in question the continuance of his love: is he
inconstant, sir, in his favours?

Val. No, believe me.

Vio. I thank you. Here comes the count.

Enter Duke, Curio, and Attendants.

Duke. Who saw Cesario, ho?

10
Vio. On your attendance, my lord; here.

Duke. Stand you a while aloof. Cesario,


Thou know'st no less but all; I have unclasp'd
To thee the book even of my secret soul:
Therefore, good youth, address thy gait unto her;
15
Be not denied access, stand at her doors,
And tell them, there thy fixed foot shall grow
Till thou have audience.

Vio. Sure, my noble lord,


If she be so abandon'd to her sorrow
As it is spoke, she never will admit me.

20
Duke. Be clamorous and leap all civil bounds
u e e c a o ous a d eap a c bou ds
Rather than make unprofited return.

Vio. Say I do speak with her, my lord, what then?

Duke. O, then unfold the passion of my love,


Surprise her with discourse of my dear faith:
25
It shall become thee well to act my woes;
She will attend it better in thy youth
Than in a nuncio's of more grave aspect.

Vio. I think not so, my lord.

Duke. Dear lad, believe it;


For they shall yet belie thy happy years,
30
That say thou art a man: Diana's lip
Is not more smooth and rubious; thy small pipe
Is as the maiden's organ, shrill and sound;
And all is semblative a woman's part.
I know thy constellation is right apt
35
For this affair. Some four or five attend him;
All, if you will; for I myself am best
When least in company. Prosper well in this,
And thou shalt live as freely as thy lord,
To call his fortunes thine.

Vio. I'll do my best


40
To woo your lady: [Aside] yet, a barful strife!
Whoe'er I woo, myself would be his wife. [Exeunt.

LINENOTES:
Scene iv.] Scene v. Pope.
The Duke's palace.] The Palace. Rowe.
[8] count] Ff. Duke Rowe.
[9] Enter ...] Ff (after line 7).
Curio, and Attendants.] attended. Capell.
[27] nuncio's] Ff. nuncio Theobald.
[32] and sound] in sound Anon. conj.
[40] lady] lady [Exit Duke] Johnson.
[Aside] Capell.
a barful] F4. a barrefull F1 F2 F3. O baneful Pope. O barful Collier (Thirlby
conj. MS.), a woeful Daniel conj.

Scene V. Olivia's house.


Enter Maria and Clown.

Mar. Nay, either tell me where thou hast been, or I


will not open my lips so wide as a bristle may enter in way
of thy excuse: my lady will hang thee for thy absence.

Clo. Let her hang me: he that is well hanged in this


5
world needs to fear no colours.

Mar. Make that good.

Clo. He shall see none to fear.

Mar. A good lenten answer: I can tell thee where that


saying was born, of 'I fear no colours.'

10
Clo. Where, good Mistress Mary?

Mar. In the wars; and that may you be bold to say


in your foolery.

Clo. Well, God give them wisdom that have it; and
those that are fools, let them use their talents.

15
Mar. Yet you will be hanged for being so long absent;
or, to be turned away, is not that as good as a
hanging to you?

Clo. Many a good hanging prevents a bad marriage;


and, for turning away, let summer bear it out.

20
Mar. You are resolute, then?
Clo. Not so, neither; but I am resolved on two points.

Mar. That if one break, the other will hold; or, if


both break, your gaskins fall.

Clo. Apt, in good faith; very apt. Well, go thy way;


25
if Sir Toby would leave drinking, thou wert as witty a
piece of Eve's flesh as any in Illyria.

Mar. Peace, you rogue, no more o' that. Here comes


my lady: make your excuse wisely, you were best. [Exit.

Clo. Wit, an't be thy will, put me into good fooling!


30
Those wits, that think they have thee, do very oft prove
fools; and I, that am sure I lack thee, may pass for a wise
man: for what says Quinapalus? 'Better a witty fool than
a foolish wit.'

Enter Lady Olivia with Malvolio.

God bless thee, lady!

35
Oli. Take the fool away.

Clo. Do you not hear, fellows? Take away the lady.

Oli. Go to, you're a dry fool; I'll no more of you: besides,


you grow dishonest.

Clo. Two faults, madonna, that drink and good counsel


40
will amend: for give the dry fool drink, then is the fool not
dry: bid the dishonest man mend himself; if he mend, he is
no longer dishonest; if he cannot, let the botcher mend him.
Any thing that's mended is but patched: virtue that
yt g t at s e ded s but patc ed tue t at
transgresses
is but patched with sin; and sin that amends is but
45
patched with virtue. If that this simple syllogism will serve,
so; if it will not, what remedy? As there is no true cuckold
but calamity, so beauty's a flower. The lady bade take
away the fool; therefore, I say again, take her away.

Oli. Sir, I bade them take away you.

50
Clo. Misprision in the highest degree! Lady, cucullus
non facit monachum; that's as much to say as I wear not
motley in my brain. Good madonna, give me leave to
prove you a fool.

Oli. Can you do it?

55
Clo. Dexteriously, good madonna.

Oli. Make your proof.

Clo. I must catechize you for it, madonna: good my


mouse of virtue, answer me.

Oli. Well, sir, for want of other idleness, I 'll bide your
60
proof.

Clo. Good madonna, why mournest thou?

Oli. Good fool, for my brother's death.

Clo. I think his soul is in hell, madonna.

Oli. I know his soul is in heaven, fool.


65
Clo. The more fool, madonna, to mourn for your brother's
soul being in heaven. Take away the fool,
gentlemen.

Oli. What think you of this fool, Malvolio? doth he


not mend?

70
Mal. Yes, and shall do till the pangs of death shake
him: infirmity, that decays the wise, doth ever make the
better fool.

Clo. God send you, sir, a speedy infirmity, for the


better increasing your folly! Sir Toby will be sworn that
75
I am no fox; but he will not pass his word for two pence
that you are no fool.

Oli. How say you to that, Malvolio?

Mal. I marvel your ladyship takes delight in such a


barren rascal: I saw him put down the other day with an
80
ordinary fool that has no more brain than a stone. Look
you now, he's out of his guard already; unless you laugh
and minister occasion to him, he is gagged. I protest, I
take these wise men, that crow so at these set kind of fools,
no better than the fools' zanies.

85
Oli. O, you are sick of self-love, Malvolio, and taste
with a distempered appetite. To be generous, guiltless and
of free disposition, is to take those things for bird-bolts that
you deem cannon-bullets: there is no slander in an allowed
fool, though he do nothing but rail; nor no railing in a
90
90
known discreet man, though he do nothing but reprove.

Clo. Now Mercury endue thee with leasing, for thou


speakest well of fools!

Re-enter Maria.

Mar. Madam, there is at the gate a young gentleman


much desires to speak with you.

95
Oli. From the Count Orsino, is it?

Mar. I know not, madam: 'tis a fair young man, and


well attended.

Oli. Who of my people hold him in delay?

Mar. Sir Toby, madam, your kinsman.

100
Oli. Fetch him off, I pray you; he speaks nothing but
madman: fie on him! [Exit Maria.] Go you, Malvolio:
if it be a suit from the count, I am sick, or not at home;
what you will, to dismiss it. [Exit Malvolio.] Now you
see, sir, how your fooling grows old, and people dislike it.

105
Clo. Thou hast spoke for us, madonna, as if thy eldest son
should be a fool; whose skull Jove cram with brains! for,—
here
he comes,—one of thy kin has a most weak pia mater.

Enter Sir Toby.

Oli. By mine honour, half drunk. What is he at the


gate, cousin?
110
Sir To. A gentleman.

Oli. A gentleman! what gentleman?

Sir To. 'Tis a gentleman here—a plague o' these pickle-


herring!
How now, sot!

Clo. Good Sir Toby!

115
Oli. Cousin, cousin, how have you come so early by
this lethargy?

Sir To. Lechery! I defy lechery. There's one at the gate.

Oli. Ay, marry, what is he?

Sir To. Let him be the devil, an he will, I care not:


120
give me faith, say I. Well, it's all one. [Exit.

Oli. What's a drunken man like, fool?

Clo. Like a drowned man, a fool and a mad man: one


draught above heat makes him a fool; the second mads
him; and a third drowns him.

125
Oli. Go thou and seek the crowner, and let him sit o'
my coz; for he's in the third degree of drink, he's drowned:
go, look after him.

Clo. He is but mad yet, madonna; and the fool shall


look to the madman. [Exit.

Re-enter Malvolio.
e e te o o

130
Mal. Madam, yond young fellow swears he will speak
with you. I told him you were sick; he takes on him to
understand so much, and therefore comes to speak with
you. I told him you were asleep; he seems to have a
foreknowledge of that too, and therefore comes to speak
135
with you. What is to be said to him, lady? he's fortified
against any denial.

Oli. Tell him he shall not speak with me.

Mal. Has been told so; and he says, he'll stand at


your door like a sheriff's post, and be the supporter to a
140
bench, but he'll speak with you.

Oli. What kind o' man is he?

Mal. Why, of mankind.

Oli. What manner of man?

Mal. Of very ill manner; he'll speak with you, will


145
you or no.

Oli. Of what personage and years is he?

Mal. Not yet old enough for a man, nor young enough
for a boy; as a squash is before 'tis a peascod, or a codling
when 'tis almost an apple: 'tis with him in standing water,
150
between boy and man. He is very well-favoured and he
speaks very shrewishly; one would think his mother's milk
were scarce out of him.
Oli. Let him approach: call in my gentlewoman.

Mal. Gentlewoman, my lady calls. [Exit.

Re-enter Maria.

155
Oli. Give me my veil: come, throw it o'er my face.
We'll once more hear Orsino's embassy.

Enter Viola, and Attendants.

Vio. The honourable lady of the house, which is she?

Oli. Speak to me; I shall answer for her. Your will?

Vio. Most radiant, exquisite and unmatchable beauty,—I


160
pray you, tell me if this be the lady of the house, for I
never saw her: I would be loath to cast away my speech,
for besides that it is excellently well penned, I have taken
great pains to con it. Good beauties, let me sustain no
scorn; I am very comptible, even to the least sinister usage.

165
Oli. Whence came you, sir?

Vio. I can say little more than I have studied, and


that question's out of my part. Good gentle one, give me
modest assurance if you be the lady of the house, that I
may proceed in my speech.

170
Oli. Are you a comedian?

Vio. No, my profound heart: and yet, by the very


fangs of malice I swear, I am not that I play. Are you
th l d f th h ?
the lady of the house?

Oli. If I do not usurp myself, I am.

175
Vio. Most certain, if you are she, you do usurp your-self;
for what is yours to bestow is not yours to reserve. But
this is from my commission: I will on with my speech in
your praise, and then show you the heart of my message.

Oli. Come to what is important in't: I forgive you the


180
praise.

Vio. Alas, I took great pains to study it, and 'tis


poetical.

Oli. It is the more like to be feigned: I pray you, keep


it in. I heard you were saucy at my gates, and allowed
185
your approach rather to wonder at you than to hear you.
If you be not mad, be gone; if you have reason, be brief:
'tis not that time of moon with me to make one in so
skipping
a dialogue.

Mar. Will you hoist sail, sir? here lies your way.

190
Vio. No, good swabber; I am to hull here a little
longer. Some mollification for your giant, sweet lady.
Tell me your mind: I am a messenger.

Oli. Sure, you have some hideous matter to deliver,


when the courtesy of it is so fearful. Speak your office.

195
Vio. It alone concerns your ear. I bring no overture
o t a o e co ce s you ea b g o o e tu e
of war, no taxation of homage: I hold the olive in my
hand; my words are as full of peace as matter.

Oli. Yet you began rudely. What are you? what


would you?

200
Vio. The rudeness that hath appeared in me have I
learned from my entertainment. What I am, and what I
would, are as secret as maidenhead; to your ears, divinity,
to any other's, profanation.

Oli. Give us the place alone: we will hear this divinity.


205
[Exeunt Maria and Attendants.] Now, sir, what is your text?

Vio. Most sweet lady,—

Oli. A comfortable doctrine, and much may be said of


it. Where lies your text?

Vio. In Orsino's bosom.

210
Oli. In his bosom! In what chapter of his bosom?

Vio. To answer by the method, in the first of his heart.

Oli. O, I have read it: it is heresy. Have you no more


to say?

Vio. Good madam, let me see your face.

215
Oli. Have you any commission from your lord to negotiate
with my face? You are now out of your text: but
we will draw the curtain and show you the picture. Look
you sir such a one I was this present: is't not well done?
you, sir, such a one I was this present: is t not well done?
[Unveiling.

Vio. Excellently done, if God did all.

220
Oli. 'Tis in grain, sir; 'twill endure wind and weather.

Vio. 'Tis beauty truly blent, whose red and white


Nature's own sweet and cunning hand laid on:
Lady, you are the cruell'st she alive,
If you will lead these graces to the grave
225
And leave the world no copy.

Oli. O, sir, I will not be so hard-hearted; I will give


out divers schedules of my beauty: it shall be inventoried,
and every particle and utensil labelled to my will: as,
item, two lips, indifferent red; item, two grey eyes, with
230
lids to them; item, one neck, one chin, and so forth. Were
you sent hither to praise me?

Vio. I see you what you are, you are too proud;
But, if you were the devil, you are fair.
My lord and master loves you: O, such love
235
Could be but recompensed, though you were crown'd
The nonpareil of beauty!

Oli. How does he love me?

Vio. With adorations, fertile tears,


With groans that thunder love, with sighs of fire.

Oli. Your lord does know my mind; I cannot love him:


240
Yet I suppose him virtuous, know him noble,
Of great estate, of fresh and stainless youth;
In voices well divulged, free, learn'd and valiant;
And in dimension and the shape of nature
A gracious person: but yet I cannot love him;
245
He might have took his answer long ago.

Vio. If I did love you in my master's flame,


With such a suffering, such a deadly life,
In your denial I would find no sense;
I would not understand it.

Oli. Why, what would you?

250
Vio. Make me a willow cabin at your gate,
And call upon my soul within the house;
Write loyal cantons of contemned love
And sing them loud even in the dead of night;
Halloo your name to the reverberate hills
255
And make the babbling gossip of the air
Cry out 'Olivia!' O, you should not rest
Between the elements of air and earth,
But you should pity me!

Oli. You might do much.


What is your parentage?

260
Vio. Above my fortunes, yet my state is well:
I am a gentleman.

Oli. Get you to your lord;


I cannot love him: let him send no more;
Unless, perchance, you come to me again,
To tell me how he takes it. Fare you well:
265
I thank you for your pains: spend this for me.

Vio. I am no fee'd post, lady; keep your purse:


My master, not myself, lacks recompense.
Love make his heart of flint that you shall love;
And let your fervour, like my master's, be
270
Placed in contempt! Farewell, fair cruelty. [Exit.

Oli. 'What is your parentage?'


'Above my fortunes, yet my state is well:
I am a gentleman.' I'll be sworn thou art;
Thy tongue, thy face, thy limbs, actions, and spirit,
275
Do give thee five-fold blazon: not too fast: soft, soft!
Unless the master were the man. How now!
Even so quickly may one catch the plague?
Methinks I feel this youth's perfections
With an invisible and subtle stealth
280
To creep in at mine eyes. Well, let it be.
What ho, Malvolio!

Re-enter Malvolio.

Mal. Here, madam, at your service.

Oli. Run after that same peevish messenger,


The county's man: he left this ring behind him,
Would I or not: tell him I'll none of it.
285
Desire him not to flatter with his lord,
Nor hold him up with hopes; I am not for him:
If that the youth will come this way to-morrow,
I'll give him reasons for't: hie thee, Malvolio.
Mal. Madam, I will. [Exit.

290
Oli. I do I know not what, and fear to find
Mine eye too great a flatterer for my mind.
Fate, show thy force: ourselves we do not owe;
What is decreed must be, and be this so. [Exit.
LINENOTES:
Scene v.] Scene vi. Pope.
Olivia's house.] Rowe.
[5] to fear] fear F3 F4.
colours] collars Anon. conj.
[8] lenten] Rowe. lenton Ff.
[16] to be] F1. be F2 F3 F4.
[18] Many] Marry, Theobald.
[19] turning away] turning o' hay Smith conj. turning of whey Letherland
conj.
[20, 28] You] Your F2.
[23] gaskins] gaskings F4.
[28] [Exit.] Pope. om. Ff.
[29] Scene vii. Pope.
an't] Hanmer. and 't Ff.
good] a good Warburton.
[34] Enter ...] Ff (after line 28). Enter O. attended. Capell.
[37] you're] y'are Ff.
[39] madonna] Madona Ff., and passim.
[46] cuckold] counsellor Hanmer.
[51] to say as I wear] to say, as I were F4. as to say, as I were Rowe (ed.
1). as to say, I wear Id. (ed. 2).
[55] Dexteriously] Dexterously F4.
[58] mouse] muse Anon. conj.
answer me] answer F3 F4.
[59] bide] abide Steevens (1785).
[65] fool] F1 F2. fool you F3 F4.
[71, 72] the better] Ff. better the Rowe (ed. 2).
[80] brain] brains F3 F4.
[83] these] those Hanmer.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

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

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like