Java TM Programming From Problem Analysis to Program Design 5th Edition D. S. Malik - The ebook version is available in PDF and DOCX for easy access
Java TM Programming From Problem Analysis to Program Design 5th Edition D. S. Malik - The ebook version is available in PDF and DOCX for easy access
https://ebookultra.com/download/c-programming-from-problem-analysis-
to-program-design-4th-ed-edition-d-s-malik/
https://ebookultra.com/download/the-java-tm-programming-language-4th-
edition-ken-arnold/
https://ebookultra.com/download/java-programs-to-accompany-
programming-logic-and-design-7th-edition-jo-ann-smith/
https://ebookultra.com/download/beginning-programming-with-java-for-
dummies-5th-edition-barry-burd/
Problem Solving and Program Design in C Third Edition Jeri
R. Hanly
https://ebookultra.com/download/problem-solving-and-program-design-in-
c-third-edition-jeri-r-hanly/
https://ebookultra.com/download/java-how-to-program-early-
objects-10th-ed-edition-deitel/
https://ebookultra.com/download/java-concepts-5th-edition-cay-s-
horstmann/
https://ebookultra.com/download/java-the-uml-way-integrating-object-
oriented-design-and-programming-else-lervik/
https://ebookultra.com/download/java-tm-application-development-on-
linux-r-1st-edition-carl-albing/
Java TM Programming From Problem Analysis to
Program Design 5th Edition D. S. Malik Digital Instant
Download
Author(s): D. S. Malik
ISBN(s): 9781111530532, 111153053X
Edition: 5
File Details: PDF, 3.43 MB
Year: 2011
Language: english
Licensed to: iChapters User
Licensed to: iChapters User
JAVA PROGRAMMING
FROM PROBLEM ANALYSIS TO PROGRAM DESIGN
FIFTH EDITION
D.S. MALIK
Australia ! Brazil ! Japan ! Korea ! Mexico ! Singapore ! Spain ! United Kingdom ! United States
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
!"#$%&$$&'(&)*+),,-*.*/00111** "2323$11133456475189
Licensed to: iChapters User
Java Programming: From Problem Analysis ª 2012 Course Technology, Cengage Learning
to Program Design, Fifth Edition
ALL RIGHTS RESERVED. No part of this work covered by the
D.S. Malik copyright herein may be reproduced, transmitted, stored or used
Executive Editor: Marie Lee in any form or by any means graphic, electronic, or mechanical,
including but not limited to photocopying, recording, scanning,
Acquisitions Editor: Brandi Shailer digitizing, taping, Web distribution, information networks, or
Senior Product Manager: Alyssa Pratt information storage and retrieval systems, except as permitted
Editorial Assistant: Jacqueline Lacaire under Section 107 or 108 of the 1976 United States Copyright Act,
without the prior written permission of the publisher.
Content Project Manager: Lisa Weidenfeld
Associate Marketing Manager: Shanna For product information and technology assistance, contact us at
Shelton Cengage Learning Customer & Sales Support, 1-800-354-9706
Art Director: Faith Brosnan For permission to use material from this text or product, submit
all requests online at www.cengage.com/permissions
Proofreader: Andrea Schein
Further permissions questions can be emailed to
Indexer: Alexandra Nickerson [email protected]
Print Buyer: Julio Esperas
Cover Designer: Roycroft Design/
www.roycroftdesign.com Library of Congress Control Number: 2010940363
Cover Photo: ª photolibrary/Richard ISBN-13: 978-1-111-53053-2
Cummins ISBN-10: 1-111-53053-x
Compositor: Integra Course Technology
20 Channel Center Street
Boston, MA 02210
Some of the product names and company
USA
names used in this book have been used for
identification purposes only and may be
trademarks or registered trademarks of their Cengage Learning is a leading provider of customized
respective manufacturers and sellers. learning solutions with office locations around the globe,
including Singapore, the United Kingdom, Australia, Mexico,
Any fictional data related to persons or
Brazil and Japan. Locate your local office at:
companies or URLs used throughout this
www.cengage.com/global
book is intended for instructional purposes
only. At the time this book was printed, any Cengage Learning products are represented in Canada by
such data was fictional and not belonging to Nelson Education, Ltd.
any real persons or companies.
To learn more about Course Technology, visit
Course Technology, a part of Cengage www.cengage.com/coursetechnology
Learning, reserves the right to revise this
Purchase any of our products at your local college store
publication and make changes from time to
or at our preferred online store www.cengagebrain.com
time in its content without notice.
The programs in this book are for
instructional purposes only. They have been
tested with care, but are not guaranteed for
any particular intent beyond educational
purposes. The author and the publisher do
not offer any warranties or representations,
nor do they accept any liabilities with respect
to the programs.
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
TO
My Daughter
Shelly Malik
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
B RIEF C ONTENTS
PREFACE xix
1. An Overview of Computers and Programming Languages 1
9. Arrays 551
INDEX 1023
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
TABLE OF C ONTENTS
Preface xix
Language of a Computer 6
Programming Methodologies 19
Structured Programming 19
Object-Oriented Programming 19
Quick Review 21
Exercises 23
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
Data Types 32
Primitive Data Types 32
Expressions 40
Mixed Expressions 41
class String 45
Strings and the Operator + 46
Input 48
Allocating Memory with Named Constants and Variables 48
Putting Data into Variables 51
Declaring and Initializing Variables 55
Input (Read) Statement 56
Reading a Single Character 61
Output 66
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
viii | Java Programming: From Problem Analysis to Program Design, Fifth Edition
Quick Review 94
Exercises 97
Input/Output 129
Formatting Output with printf 129
Using Dialog Boxes for Input/Output 139
Formatting the Output Using the String Method format 146
Exercises 167
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
Table of Contents | ix
Exercises 232
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
Exercises 306
Exercises 378
Table of Contents | xi
Exercises 445
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
xii | Java Programming: From Problem Analysis to Program Design, Fifth Edition
Finalizers 507
Exercises 538
ARRAYS 551
9 Why Do We Need Arrays? 552
Arrays 553
Alternate Ways to Declare an Array 555
Accessing Array Elements 555
Specifying Array Size during Program Execution 557
Array Initialization during Declaration 558
Arrays and the Instance Variable length 558
Processing One-Dimensional Arrays 559
Array Index Out of Bounds Exception 564
Declaring Arrays as Formal Parameters to Methods 564
Assignment Operator, Relational Operators, and Arrays:
A Precaution 565
Arrays as Parameters to Methods 567
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
Exercises 623
Polymorphism 664
Operator instanceof 670
Interfaces 681
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
xiv | Java Programming: From Problem Analysis to Program Design, Fifth Edition
Exercises 712
Exercises 777
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
Table of Contents | xv
Menus 844
Exercises 866
RECURSION 873
13
Recursive Definitions 874
Direct and Indirect Recursion 876
Infinite Recursion 877
Designing Recursive Methods 877
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
xvi | Java Programming: From Problem Analysis to Program Design, Fifth Edition
Exercises 897
Exercises 934
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
Chapter 2 998
Chapter 3 1001
Chapter 4 1002
Chapter 5 1004
Chapter 6 1007
Chapter 7 1008
Chapter 8 1010
Chapter 9 1014
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
xviii | Java Programming: From Problem Analysis to Program Design, Fifth Edition
Chapter 10 1016
Chapter 11 1018
Chapter 12 1019
Chapter 13 1020
Chapter 14 1020
INDEX 1023
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
Welcome to Java Programming: From Problem Analysis to Program Design, Fifth Edition.
Designed for a first Computer Science (CS1) Java course, this text will provide a breath of
fresh air to you and your students. The CS1 course serves as the cornerstone of the Computer
Science curriculum. My primary goal is to motivate and excite all programming students,
regardless of their level. Motivation breeds excitement for learning. Motivation and excite-
ment are critical factors that lead to the success of the programming student. This text is the
culmination and development of my classroom notes throughout more than fifty semesters of
teaching successful programming.
Warning: This text can be expected to create a serious reduction in the demand for program-
ming help during your office hours. Other side effects include significantly diminished student
dependency on others while learning to program.
The primary focus in writing this text is on student learning. Therefore, in addition to clear
explanations, we address the key issues that otherwise impede student learning. For example, a
common question that arises naturally during an early programming assignment is: ‘‘How
many variables and what kinds are needed in this program?’’ We illustrate this important and
crucial step by helping students learn why variables are needed and how data in a variable is
manipulated. Next students learn that the analysis of the problem will spill the number and
types of the variables. Once students grasp this key concept, control structures (selection and
loops) become easier to learn. The second major impediment in learning programming is
parameter passing. We pay special attention to this topic. First students learn how to use
predefined methods and how actual and formal parameters relate. Next students learn about
user-defined methods. They see visual diagrams that help them learn how methods are called
and how formal parameters affect actual parameters. Once students have a clear understanding
of these two key concepts, they readily assimilate advanced topics.
The topics are introduced at a pace that is conducive to learning. The writing style is friendly,
engaging, and straightforward. It parallels the learning style of the contemporary CS1 student.
Before introducing a key concept, the student learns why the concept is needed, and then sees
examples illustrating the concept. Special attention is paid to topics that are essential in
mastering the Java programming language and in acquiring a foundation for further study
of computer science.
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
Other important topics include debugging techniques and techniques for avoiding programming
bugs. When a beginner compiles his/her first program and sees that the number of errors exceeds the
length of this first program, he/she becomes frustrated by the plethora of errors, only some of which
can be interpreted. To ease this frustration and help students learn to produce correct programs,
debugging and bug avoidance techniques are presented systematically throughout the text.
Approach
Once conceived as a Web programming language, Java slowly but surely found its way into
classrooms where it now serves as a first programming language in computer science curricula
(CS1). Java is a combination of traditional style programming—programming with a non-
graphical user interface—and modern style programming with a graphical user interface
(GUI). This book introduces you to both styles of programming. After giving a brief
description of each chapter, we discuss how to read this book.
Chapter 1 briefly reviews the history of computers and programming languages. The reader
can quickly skim and become familiar with some of the hardware and software components of
the computer. This chapter also gives an example of a Java program and describes how a Java
program is processed. The two basic problem-solving techniques, structured programming
and object-oriented design, are also presented.
After completing Chapter 2, students become familiar with the basics of Java and are ready to
write programs that are complicated enough to do some computations. The debugging section
in this chapter illustrates how to interpret and correct syntax errors.
The three terms that you will encounter throughout the book are—primitive type variables,
reference variables, and objects. Chapter 3 makes clear distinctions between these terms and
sets the tone for the rest of the book. An object is a fundamental entity in an object-oriented
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
programming language. This chapter further explains how an object works. The class
String is one of the most important classes in Java. This chapter introduces this class and
explains how various methods of this class can be used to manipulate strings. Because input/
output is fundamental to any programming language, it is introduced early, and is covered in
detail in Chapter 3. The debugging section in this chapter illustrates how to find and correct
logical errors.
Chapters 4 and 5 introduce control structures used to alter the sequential flow of execution.
The debugging sections in these chapters discuss and illustrate logical errors associated with
selection and looping structures.
Java is equipped with powerful yet easy-to-use graphical user interface (GUI) components
to create user-friendly graphical programs. Chapter 6 introduces various GUI components
and gives examples of how to use these components in Java application programs. Because
Java is an object-oriented programming language, the second part of Chapter 6 discusses
and gives examples of how to solve various problems using object-oriented design
methodology.
Chapter 7 discusses user-defined methods. Parameter passing is a fundamental concept in any
programming language. Several examples, including visual diagrams, help readers understand
this concept. It is recommended that readers with no prior programming background spend
extra time on this concept. The debugging section in this chapter discuss how to debug a
program using stubs and drivers.
Chapter 8 discusses user-defined classes. In Java, a class is an important and widely used
element. It is used to create Java programs, group related operations, and it allows users to
create their own data types. This chapter uses extensive visual diagrams to illustrate how
objects of classes manipulate data.
Chapter 9 describes arrays. This chapter also introduces variable length formal parameter lists.
In addition, this chapter introduces foreach loops and explains how this loop can be used to
process the elements of an array. This chapter also discusses the sequential searching algorithm
and the class Vector.
Inheritance is an important principle of object-oriented design. It encourages code reuse.
Chapter 10 discusses inheritance and gives various examples to illustrate how classes are
derived from existing classes. In addition, this chapter also discusses polymorphism, abstract
classes, inner classes, and composition.
An occurrence of an undesirable situation that can be detected during program execution is
called an exception. For example, division by zero is an exception. Java provides extensive
support for handing exceptions. Chapter 11 shows how to handle exceptions in a program.
Chapter 11 also discusses event handling, which was introduced in Chapter 6. Chapter 12
picks up the discussion of GUI components started in Chapter 6. This chapter introduces
additional GUI components and discusses how to create applets.
Chapter 13 introduces recursion. Several examples illustrate how recursive methods
execute.
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
xxii | Java Programming: From Problem Analysis to Program Design, Fifth Edition
Chapter 14 discusses a binary search algorithm as well as bubble sort, selection sort, insertion
sort, and quick sort algorithms. Additional content covering the sorting algorithms bubble sort
and quick sort is provided online at www.cengagebrain.com.
Appendix A lists the reserved words in Java. Appendix B shows the precedence and
associativity of the Java operators. Appendix C lists the ASCII (American Standard Code
for Information Interchange) portion of the Unicode character set as well as the EBCDIC
(Extended Binary Code Decimal Interchange) character set.
Appendix D contains additional topics in Java. The topics covered are converting a base 10
number to binary (base 2) number and vice versa, converting a number from base 2 to base 8 (base
16) and vice versa, how to compile and execute a Java program using command line statements,
how to create Java style documentation of the user-defined classes, how to create packages, how to
use user-defined classes in a Java program, and enum type. Appendix E gives answers to the odd-
numbered exercises in the text. Those odd-numbered exercises with very long solutions will not
be in the text, but will be provided to students online at www.cengagebrain.com.
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
Figure 1 shows a chapter dependency diagram for this book. Solid arrows indicate that the
chapter at the beginning of the arrow is required before studying the chapter at the end of the
arrow. A dotted arrow indicates that the chapter at the beginning of the arrow is not essential
to studying the chapter at the end of the dotted arrow.
Chapter 1
Chapter 2
Chapter 3
Chapter 4
Chapter 5
Chapter 6 Chapter 7
Chapter 8 Chapter 9
Chapter 10 Chapter 14
Chapter 11
Chapter 12
Chapter 13
A dotted arrow means that the chapter is not essential to studying the following chapter.
All source code and solutions have been written, compiled, and quality assurance tested
with Java 6.0 and the version of Java 7.0 available at the time this book was being typeset.
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
Four-color
interior design
shows
accurate code
and related
comments.
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
The debugging
sections show
how to find
and correct
syntax and
semantic
(logical)
errors.
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
More than
250 visual
diagrams,
both
extensive and
exhaustive,
illustrate difficult
concepts.
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
Numbered Examples
illustrate the key
concepts with their
relevant code. The
programming code in
these examples is
followed by a Sample
Run. An explanation
then follows that
describes what each
line in the code does.
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
Notes highlight
important facts
about the concepts
introduced in the
chapter.
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
Programming
Examples are
complete programs
featured in each
chapter. These
examples include the
accurate, concrete
stages of Input,
Output, Problem
Analysis and Algorithm
Design, and a
Complete Program
Listing.
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
Exercises further
reinforce learning
and ensure that
students have, in
fact, mastered the
material.
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
Programming
Exercises challenge
students to write
Java programs with
a specified
outcome.
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
S UPPLEMENTAL
R ESOURCES
The following supplemental materials are available when this book is used in a classroom setting.
Most instructor teaching tools, outlined below, are available with this book on a single
CD-ROM, and are also available for instructor access at login.cengage.com.
ExamView!
This textbook is accompanied by ExamView, a powerful testing software package that allows
instructors to create and administer printed, computer (LAN-based), and Internet exams.
ExamView includes hundreds of questions that correspond to the topics covered in this text,
enabling students to generate detailed study guides that include page references for further
review. These computer-based and Internet testing components allow students to take exams
at their computers, and save the instructor time because each exam is graded automatically.
PowerPoint Presentations
Microsoft PowerPoint slides are available for each chapter. These slides are provided as a teaching
aid for classroom presentations, either to make available to students on the network for chapter
review, or to be printed for classroom distribution. Instructors can add their own slides for
additional topics that they introduce to the class.
Distance Learning
Course Technology is proud to present online courses in WebCT and Blackboard to provide
the most complete and dynamic learning experience possible. For more information on how
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
xxxiv | Java Programming: From Problem Analysis to Program Design, Fifth Edition
to bring distance learning to your course, contact your local Course Technology sales
representative.
Source Code
The source code is available for students at www.cengagebrain.com. At the cengagebrain.com home
page, search for the ISBN of your title (from the back cover of your book) using the search
box at the top of the page. This will take you to the product page where these resources can
be found. The source code is also available on the Instructor Resources CD-ROM. The
input files needed to run some of the programs are also included with the source code.
Solution Files
The solution files for all programming exercises are available for instructor download at
http://login.cengage.com and are also available on the Instructor Resources CD-ROM. The
input files needed to run some of the programming exercises are also included with the
solution files.
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
A CKNOWLEDGMENTS
There are many people I must thank who, in one way or another, contributed to the success
of this book. First, I would like to thank those who e-mailed numerous comments that helped
to improve on the fourth edition. I am thankful to Professors S.C. Cheng and Randall Crist
for constantly supporting this project.
I owe a great deal to the following reviewers, who patiently read each page of every chapter
of the current version and made critical comments that helped to improve the book:
Nadimpalli Mahadev, Fitchburg State College and Baoqiang Yan, Missouri Western State
University. Additionally, I would like to thank Brian Candido, Springfield Technical Com-
munity College, for his review of the proposal package. The reviewers will recognize that
their suggestions have not been overlooked and, in fact, made this a better book.
Next, I express thanks to Brandi Shailer, Acquisitions Editor, for recognizing the importance
and uniqueness of this project. All this would not have been possible without the careful
planning of Senior Product Manager Alyssa Pratt. I extend my sincere thanks to Alyssa, as well
as to Content Project Manager, Lisa Weidenfeld. I also thank Sreejith Govindan of Integra
Software Services for assisting us in keeping the project on schedule. I would like to thank
Chris Scriver and Serge Palladino of the MQA department of Course Technology for patiently
and carefully proofreading the text, testing the code, and discovering typos and errors.
I am thankful to my parents for their blessings.
Finally, I am thankful to the support of my wife Sadhana, and especially my daughter Shelly,
to whom this book is dedicated. They cheered me up whenever I was overwhelmed during
the writing of this book.
We welcome any comments concerning the text. Comments may be forwarded to the
following e-mail address: [email protected].
D.S. Malik
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
APPENDIX A
J AVA R ESERVED
W ORDS
The reserved words const and goto are not currently in use.
939
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
APPENDIX B
O PERATOR
P RECEDENCE
The following table shows the precedence of operators in Java from highest to lowest,
and their associativity.
941
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
APPENDIX C
C HARACTER S ETS
This appendix lists and describes the character sets for ASCII (American Standard Code
for Information Interchange), which also comprises the first 128 characters of the Uni-
code character set, and EBCDIC (Extended Binary Coded Decimal Interchange Code).
ASCII
0 1 2 3 4 5 6 7 8 9
0 nul soh stx etx eot enq ack bel bs ht
1 lf vt ff cr so si dle dc1 dc2 dc3
2 dc4 nak syn etb can em sub esc fs gs
3 rs us b ! " # $ % & '
4 ( ) * + , - . / 0 1
5 2 3 4 5 6 7 8 9 : ;
6 < ¼ > ? @ A B C D E
7 F G H I J K L M N O
8 P Q R S T U V W X Y
9 Z [ \ ] ^ _ ` a b c
10 d e f g h i j k l m
11 n o p q r s t u v w
12 x y z { | } " del
945
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Another Random Scribd Document
with Unrelated Content
The Project Gutenberg eBook of Azul...
This ebook is for the use of anyone anywhere in the United
States and most other parts of the world at no cost and with
almost no restrictions whatsoever. You may copy it, give it away
or re-use it under the terms of the Project Gutenberg License
included with this ebook or online at www.gutenberg.org. If you
are not located in the United States, you will have to check the
laws of the country where you are located before using this
eBook.
Title: Azul...
Language: Spanish
AL ÍNDICE
A D. Rubén Darío.
Madrid, 22 de Octubre de 1888.
I
ODO libro, que desde América llega a mis manos, excita mi interés
y despierta mi curiosidad; pero ninguno hasta hoy la ha
despertado tan viva como el de usted, no bien comencé a leerlo.
Confieso que al principio, a pesar de la amable dedicatoria con
que usted me envía un ejemplar, miré el libro con indiferencia... casi con
desvío. El título Azul... tuvo la culpa.
Víctor Hugo dice: L’art c’est l’azur; pero yo no me conformo ni me
resigno con que tal dicho sea muy profundo y hermoso. Para mí, tanto vale
decir que el arte es lo azul, como decir que es lo verde, lo amarillo o lo rojo.
¿Por qué, en este caso, lo azul (aunque en francés no sea bleu, sino azur,
que es más poético) ha de ser cifra, símbolo y superior predicamento que
abarque lo ideal, lo etéreo, lo infinito, la serenidad del cielo sin nubes, la luz
difusa, la amplitud vaga y sin límites, donde nacen, viven, brillan y se
mueven los astros? Pero aunque todo esto y más surja del fondo de nuestro
ser y aparezca a los ojos del espíritu, evocado por la palabra azul, ¿qué
novedad hay en decir que el arte es todo esto? Lo mismo es decir que el arte
es imitación de la Naturaleza, como lo definió Aristóteles: la percepción de
todo lo existente y de todo lo posible, y su reaparición o representación por
el hombre en signos, letras, sonidos, colores o líneas. En suma: yo, por más
vueltas que le doy, no veo en eso de que el arte es lo azul sino una frase
enfática y vacía.
Sea, no obstante, el arte azul, o del color que se quiera. Como sea bueno,
el color es lo que menos importa. Lo que a mí me dió mala espina fué la
frase de Víctor Hugo, y el que usted hubiese dado por título a su libro la
palabra fundamental de la frase. ¿Si será éste, me dije, uno de tantos y
tantos como por todas partes, y sobre todo en Portugal y en la América
española, han sido inficionados por Víctor Hugo? La manía de imitarle ha
hecho verdaderos estragos, porque la atrevida juventud exagera sus
defectos, y porque eso que se llama genio, y que hace que los defectos se
perdonen y tal vez se aplaudan, no se imita cuando no se tiene. En
resolución yo sospeché que era usted un Víctor Huguito y estuve más de
una semana sin leer el libro de usted.
No bien le he leído, he formado muy diferente concepto. Usted es usted
con gran fondo de originalidad y de originalidad muy extraña. Si el libro,
impreso en Valparaíso este año de 1888, no estuviese en muy buen
castellano, lo mismo podría ser de un autor francés, que de un italiano, que
de un turco o de un griego. El libro está impregnado de espíritu
cosmopolita. Hasta el nombre y apellido del autor, verdaderos o
contrahechos y fingidos, hacen que el cosmopolitismo resalte más. Rubén
es judaico, y persa es Darío; de suerte que por los nombres no parece sino
que usted quiere ser o es de todos los países, castas y tribus.
El libro Azul... no es en realidad un libro; es un folleto de 132 páginas;
pero tan lleno de cosas y escrito por estilo tan conciso, que da no poco en
qué pensar y tiene bastante que leer. Desde luego se conoce que el autor es
muy joven: que no puede tener más de veinticinco años, pero que los ha
aprovechado maravillosamente. Ha aprendido muchísimo, y en todo lo que
sabe y expresa muestra singular talento artístico y poético.
Sabe con amor la antigua literatura griega; sabe de todo lo moderno
europeo. Se entrevé, aunque no hace gala de ello, que tiene el concepto
cabal del mundo visible y del espíritu humano, tal como este concepto ha
venido a formarse por el conjunto de observaciones, experiencias, hipótesis
y teorías más recientes. Y se entrevé también que todo esto ha penetrado en
la mente del autor, no diré exclusivamente, pero sí principalmente, a través
de libros franceses. Es más: en los perfiles, en los refinamientos, en las
exquisiteces del pensar y del sentir del autor hay tanto de francés, que yo
forjé una historia a mi antojo para explicármela. Supuse que el autor, nacido
en Nicaragua, había ido a París a estudiar para médico o para ingeniero, o
para otra profesión; que en París había vivido seis o siete años, con artistas,
literatos, sabios y mujeres alegres de por allá; y que mucho de lo que sabe
lo había aprendido de viva voz, y empíricamente, con el trato y roce de
aquellas personas. Imposible me parecía que de tal manera se hubiese
impregnado el autor del espíritu parisiense novísimo sin haber vivido en
París durante años.
Extraordinaria ha sido mi sorpresa cuando he sabido que usted, según
me aseguran sujetos bien informados, no ha salido de Nicaragua sino para ir
a Chile en donde reside desde hace dos años a lo más. ¿Cómo, sin el influjo
del medio ambiente, ha podido usted asimilarse todos los elementos del
espíritu francés, si bien conservando española la forma que auna y organiza
estos elementos, convirtiéndolos en substancia propia?
Yo no creo que se ha dado jamás caso parecido con ningún español
peninsular. Todos tenemos un fondo de españolismo que nadie nos arranca
ni a veinticinco tirones. En el famoso abate Marchena, con haber residido
tanto tiempo en Francia, se ve el español; en Cienfuegos es postizo el
sentimentalismo empalagoso a lo Rousseau, y el español está por bajo.
Burgos y Reinoso son afrancesados y no franceses. La cultura de Francia,
buena o mala, no pasa nunca de la superficie. No es más que un barniz
transparente, detrás del cual se descubre la condición española.
Ninguno de los hombres de letras de la Península, que he conocido yo,
con más espíritu cosmopolita, y que más largo tiempo han residido en
Francia y que han hablado mejor el francés y otras lenguas extranjeras, me
ha parecido nunca tan compenetrado del espíritu de Francia como usted me
parece: ni Galiano, ni don Eugenio de Ochoa, ni Miguel de los Santos
Alvarez. En Galiano habla como una mezcla de anglicismo y de filosofismo
francés del siglo pasado; pero todo sobrepuesto y no combinado con el ser
de su espíritu, que era castizo. Ochoa era y siguió siendo siempre archi y
ultraespañol, a pesar de sus entusiasmos por las cosas de Francia. Y en
Alvarez, en cuya mente bullen las ideas de nuestro siglo, y que ha vivido
años en París, está arraigado el ser del hombre de Castilla, y en su prosa
recuerda el lector a Cervantes y a Quevedo, y en sus versos a Garcilaso y a
León, aunque así en versos como en prosa, emita él siempre ideas más
propias de nuestro siglo que de los que pasaron. Su chiste no es el esprit
francés, sino el humor español de las novelas picarescas y de los autores
cómicos de nuestra peculiar literatura.
Veo, pues, que no hay autor en castellano más francés que usted, y lo
digo para afirmar un hecho sin elogio y sin censura. En todo caso, más bien
lo digo como elogio. Yo no quiero que los autores no tengan carácter
nacional; pero yo no puedo exigir de usted que sea nicaragüense, porque ni
hay ni puede haber aún historia literaria, escuela y tradiciones literarias en
Nicaragua. Ni puedo exigir de usted que sea literariamente español, pues ya
no lo es políticamente, y está además separado de la madre patria por el
Atlántico, y más lejos en la república donde ha nacido, de la influencia
española que en otras repúblicas hispanoamericanas. Estando así disculpado
el galicismo de la mente, es fuerza dar a usted alabanzas a manos llenas por
lo perfecto y profundo de ese galicismo; porque el lenguaje persiste
español, legítimo y de buena ley, y porque si no tiene usted carácter
nacional, posee carácter individual.
En mi sentir hay en usted una poderosa individualidad de escritor, ya
bien marcada, y que, si Dios da a usted la salud que yo le deseo y larga
vida, ha de desenvolverse y señalarse más con el tiempo en obras que sean
gloria de las letras hispanoamericanas.
Leídas las 132 páginas de Azul... lo primero que se nota es que está usted
saturado de toda la más flamante literatura francesa: Hugo, Lamartine,
Musset, Baudelaire, Leconte de Lisle, Gautier, Bourget, Sully-Prouhomme,
Daudet, Zola, Barbey d’Aurevilly, Catulle Mendes, Rollinat, Goncourt,
Flaubert y todos los demás poetas y novelistas han sido por usted bien
estudiados y mejor comprendidos. Y usted no imita a ninguno: ni es usted
romántico, ni naturalista, ni neurótico, ni decadente, ni simbólico, ni
parnasiano. Usted lo ha revuelto todo: lo ha puesto a cocer en el alambique
de su cerebro, y ha sacado de ello una rara quinta esencia.
Resulta de aquí un autor nicaragüense, que jamás salió de Nicaragua
sino para ir a Chile, y que es autor tan a la moda de París y con tanto chic y
distinción, que se adelanta a la moda y pudiera modificarla e imponerla.
En el libro hay Cuentos en prosa y seis composiciones en verso. En los
cuentos y en las poesías todo está cincelado, burilado, hecho para que dure,
con primor y esmero, como pudiera haberlo hecho Flaubert, o el parnasiano
más atildado. Y, sin embargo, no se nota el esfuerzo, ni el trabajo de la lima,
ni la fatiga del rebuscar: todo parece espontáneo y fácil y escrito al correr
de la pluma, sin mengua de la concisión, de la precisión y de la extremada
elegancia. Hasta las rarezas extravagantes y salidas de tono, que a mí me
chocan, pero que acaso agraden en general, están hechas adrede. Todo en el
librito está meditado y criticado por el autor, sin que su crítica previa o
simultánea de la creación perjudique al brío apasionado y a la inspiración
del que crea.
Si se me preguntase qué enseña su libro de usted y de qué trata,
respondería yo sin vacilar: no enseña nada, y trata de nada y de todo. Es
obra de artista, obra de pasatiempo, de mera imaginación. ¿Qué enseña o de
qué trata un dije, un camafeo, un esmalte, una pintura o una linda copa
esculpida?
Hay, sin embargo, notable diferencia en toda escultura, pintura, dije y
hasta música, y cualquier objeto de arte cuyo material es la palabra. El
mármol, el bronce y el sonido no diré yo que sutilizando mucho no puedan
significar algo de por sí; pero la palabra, no sólo puede significar, sino que
forzosamente significa ideas, sentimientos, creencias, doctrinas y todo el
pensamiento humano. Nada más factible, a mi ver (acaso porque soy poco
agudo), que una bella estatua, un lindo dije, un cuadro primoroso, sin
transcendencia o sin símbolos; pero ¿cómo escribir un cuento o unas coplas
sin que deje ver el autor lo que niega, lo que afirma, lo que piensa y lo que
siente? El pensamiento en todas las artes pasa con la forma desde la mente
del artista a la substancia o materia del arte; pero en el arte de la palabra,
además del pensamiento que pose el arte en la forma, la substancia o
materia del artista es pensamiento también y pensamiento de artista. La
única materia extraña al artista es el Diccionario, con las reglas
gramaticales que siguen las voces en su combinación; pero como ni
palabras ni combinaciones de palabras pueden darse sin sentido, de aquí
que materia y forma sean en poesía y en prosa creación del escritor o del
poeta: sólo quedan fuera de él, digámoslo así, los signos hueros, o sea
abstrayendo lo significado.
De esta suerte se explica cómo, con ser su libro de usted de pasatiempo,
y sin propósito de enseñar nada, en él se ven patentes las tendencias y los
pensamientos del autor sobre las cuestiones más trascendentales. Y justo es
que confesemos que los dichos pensamientos no son ni muy edificantes ni
muy consoladores.
La ciencia de experiencia y de observación ha clasificado cuanto hay, y
ha hecho de ello hábil inventario. La crítica histórica, la lingüística y el
estudio de las capas que forman la corteza del globo han descubierto
bastante de los pasados hechos humanos que antes se ignoraban; de los
astros que brillan en la extensión del éter se sabe muchísimo; el mundo de
lo imperceptiblemente pequeño se nos ha revelado merced al microscopio;
hemos averiguado cuántos ojos tiene tal insecto y cuántas patitas tiene tal
otro: sabemos ya de qué elementos se componen los tejidos orgánicos, la
sangre de los animales y el jugo de las plantas: nos hemos aprovechado de
agentes que antes se substraían al poder humano, como la electricidad; y
gracias a la estadística, llevamos minuciosa cuenta de cuánto se engendra y
de cuánto se devora; y si ya no se sabe, es de esperar que pronto se sepa la
cifra exacta de los panecillos, del vino y de la carne que se come y se bebe
la humanidad de diario.
No es menester acudir a sabios profundos: cualquier sabio adocenado y
medianejo de nuestra edad conoce hoy, clasifica y ordena los fenómenos
que hieren los sentidos corporales, auxiliados estos sentidos por
instrumentos poderosos que aumentan su capacidad de percepción. Además
se han descubierto, a fuerza de paciencia y de agudeza y por virtud de la
dialéctica y de las matemáticas, gran número de leyes que dichos
fenómenos siguen.
Natural es que el linaje humano se haya ensoberbecido con tamaños
descubrimientos e invenciones; pero, no sólo en torno y fuera de la esfera
de lo conocido y circunscribiéndola, sino también llenándola en lo esencial
y substancial, queda un infinito inexplorado, una densa e impenetrable
obscuridad, que parece más tenebrosa por la misma contraposición de la luz
con que ha bañado la ciencia la pequeña suma de cosas que conoce. Antes,
ya las religiones con sus dogmas, que aceptaba la fe, ya la especulación
metafísica con la gigante máquina de sus brillantes sistemas, encubrían esa
inmensidad incognoscible, o la explicaban y la daban a conocer a su modo.
Hoy priva el empeño de que no haya ni metafísica ni religión. El abismo de
lo incognoscible queda así descubierto y abierto, y nos atrae y nos da
vértigo, y nos comunica el impulso, a veces irresistible, de arrojarnos en él.
La situación, no obstante, no es incómoda para la gente sensata de cierta
ilustración y fuste. Prescinden de lo transcendente y de lo sobrenatural para
no calentarse la cabeza ni perder el tiempo en balde. Esta inclinación les
quita no pocas aprensiones y cierto miedo, aunque a veces les infunde otro
miedo y sobresalto fastidiosos. ¿Cómo contener a la plebe, a los
menesterosos, hambrientos e ignorantes, sin ese freno que ellos han
desechado con tanto placer? Fuera de este miedo que experimentan algunos
sensatos, en todo lo demás no ven sino motivo de satisfacción y parabienes.
Los insensatos, en cambio, no se aquietan con el goce del mundo,
hermoseado por la industria e inventiva humanas, ni con lo que se sabe, ni
con lo que se fabrica, y anhelan averiguar y gozar más.
El conjunto de los seres, el Universo, todo cuanto alcanza a percibir la
vista y el oído, ha sido, como idea, coordinado metódicamente en una
anaquelería o casillero para que se comprenda mejor; pero ni este orden
científico, ni el orden natural, tal como los insensatos le ven, les satisface.
La molicie y el regalo de la vida moderna los han hecho muy
descontentadizos.
Y así ni del mundo tal como es, ni del mundo tal como lo concebimos, se
forman idea muy aventajada. Se ve en todo faltas, y no se dice lo que dicen
que dijo Dios: Que todo era bueno. La gente se lanza con más frecuencia
que nunca a decir que todo es malo; y en vez de atribuir la obra a un artífice
inteligentísimo y supremo, la supone obra de un puritano inconsciente de
fabricar cosas que hay ab eterno en los átomos, los cuales tampoco se sabe
a punto fijo lo que sean.
Los dos resultados principales de todo ello en la literatura de última
moda son:
1.º Que se suprima a Dios o que no se le miente sino para insolentarse
con él, ya con reniegos y maldiciones, ya con burlas y sarcasmos.
Y 2.º Que en este infinito tenebroso e incognoscible perciba la
imaginación, así como en el éter, nebulosas o semilleros de astros,
fragmentos y escombros de religiones muertas, con los cuales procura
formar algo como ensayo de nuevas creencias y de renovadas mitologías.
Estos dos rasgos van impresos en su librito de usted: El pesimismo,
como remate de toda descripción de lo que conocemos, y la poderosa y
lozana producción de seres fantásticos, evocados o sacados de las tinieblas
de lo incognoscible, donde vagan las ruinas de las destrozadas creencias y
supersticiones vetustas.
Ahora será bien que yo cite muestras y pruebe que hay en su libro de
usted, con notable elegancia, todo lo que afirmo; pero esto requiere segunda
carta.
II
En la cubierta del libro que me ha enviado usted veo que ha publicado
usted ya, o anuncia la publicación de otros varios, cuyos títulos son:
Epístolas y poemas, Rimas, Abrojos, Estudios críticos, Albumes y abanicos,
Mis conocidos y Dos años en Chile. Anuncia también dicha cubierta que
prepara usted una novela, cuyo título nos da en las narices del alma (pues si
hay ojos del alma o tiene el alma ojos, bien puede tener narices) con un
tufillo a pornografía. La novela se titula: La carne.
Nada de esto, con todo, me sirve hoy para juzgar a usted, pues yo nada
de esto conozco. Tengo que contraerme al libro Azul.
En este libro no sé qué debo preferir: si la prosa o los versos. Casi me
inclino a ver mérito igual en ambos modos de expresión del pensamiento de
usted. En la prosa hay más riqueza de ideas; pero es más afrancesada la
forma. En los versos la forma es más castiza. Los versos de usted se
parecen a los versos españoles de otros autores, y no por eso dejan de ser
originales; no recuerdan a ningún poeta español, ni antiguo, ni de nuestros
días.
El sentimiento de la Naturaleza raya en usted en adoración panteística.
Hay en las cuatro composiciones a (a o más bien en) las cuatro estaciones
del año, la más gentílica exuberancia de amor sensual, y, en este amor, algo
de religioso.
Cada composición parece un himno sagrado a Eros, himno que, a las
veces, en la mayor explosión de entusiasmo, el pesimismo viene a turbar
con la disonancia, ya de un ay de dolor, ya de una carcajada sarcástica.
Aquel sabor amargo, que brota del centro mismo de todo deleite, y que tan
bien experimentó y expresó el ateo Lucrecio,
Pero, como en usted hay de todo, noto en los versos, además del ansia
del deleite y además de la amargura de que habla Lucrecio, la sed de lo
eterno, esa aspiración profunda e insaciable de las edades cristianas, que el
poeta pagano quizá no hubiera comprendido.
Usted pide siempre más al hada, y...
«El hada entonces me llevó hasta el velo
que nos cubre las ansias infinitas,
la inspiración profunda
y el alma de las liras.
Y lo rasgó. Y allí todo era aurora.»
Suprimo, como dije ya, los versos que siguen y que no pasan de ocho,
donde se habla de la risa que le dió a Satanás de resultas del lance y de lo
pensativo que se quedó el Señor en su trono.
Entre las cuatro composiciones en las estaciones del año, todas bellas y
raras, sobresale la del verano. Es un cuadro simbólico de los dos polos
sobre los que rueda el eje de la vida: el amor y la lucha; el prurito de
destrucción y el de reproducción. La tigre virgen en celo está
magistralmente pintada, y mejor aún acaso el tigre galán y robusto que llega
y la enamora.
«Después el misterioso
tacto, las impulsivas
fuerzas que arrastran con poder pasmoso,
y ¡oh gran Pan! el idilio monstruoso
bajo las vastas selvas primitivas.»
El príncipe de Gales, que andaba de caza por allí con gran séquito de
monteros y jauría de perros, viene a poner trágico fin al idilio.
El príncipe mata a la tigre de un escopetazo. El tigre se salva, y luego en
su gruta tiene un extraño sueño:
«Que enterraba las garras y los dientes
en vientres sonrosados
y pechos de mujer; y que engullía
por postres delicados
de comidas y cenas,
como tigre goloso entre golosos,
unas cuantas docenas
de niños tiernos, rubios y sabrosos.»
No parece sino que, en sentir del poeta, tendría menos culpa el tigre,
aunque fuese ser responsable, devorando mujeres y niños, que el príncipe
matando tigres. El afecto del poeta se extiende casi por igual sobre tigres y
sobre príncipes, a quienes un determinismo fatal mueve a matarse
recíprocamente, como el ratón y el gato de la fábula de Alvarez.
Los cuentos en prosa son más singulares aún. Parecen escritos en París,
y no en Nicaragua ni en Chile. Todos son brevísimos. Usted hace gala de
laconismo. La Ninfa es quizá el que más me gusta. La cena en la quinta de
la cortesana está bien descrita. El discurso del sabio prepara el ánimo del
lector. Los límites, que tal vez no existan, pero que todos imaginamos,
trazamos y ponemos entre lo natural y sobrenatural, se esfuman y
desaparecen. San Antonio vió en el yermo un hipocentauro y un sátiro.
Alberto Magno habla también de sátiros que hubo en su tiempo. ¿Por qué
ha de ser esto falso? ¿Por qué no ha de haber sátiros, faunos y ninfas? La
cortesana anhela ver un sátiro vivo; el poeta, una ninfa. La aparición de la
ninfa desnuda al poeta, en el parque de la quinta, a la mañana siguiente, en
la umbría apartada y silenciosa, entre los blancos cisnes del estanque, está
pintada con tal arte que parece verdad.
La ninfa huye y queda burlado el poeta; pero en el almuerzo, dice luego
la cortesana:
«—El poeta ha visto ninfas.»
«Todos la contemplaron asombrados, y ella me miraba como una gata, y
se reía, se reía como una chicuela a quien se le hiciesen cosquillas.»
El velo de la reina Mab es precioso. Empieza así:
«La reina Mab, en su carro hecho de una sola perla tirado por cuatro
coleópteros de petos dorados y alas de pedrería, caminando sobre un rayo
de sol, se coló un día por la ventana de una boardilla, donde estaban cuatro
hombres flacos, barbudos e impertinentes, lamentándose como unos
desdichados.»
Eran un pintor, un escultor, un músico y un poeta. Cada cual hace su
lastimoso discurso, exponiendo aspiraciones y desengaños. Todos terminan
en la desesperación.
«Entonces la reina Mab, del fondo de su carro, hecho de una sola perla,
tomó un velo azul, casi impalpable, como formado de suspiros o miradas de
ángeles rubios y pensativos. Y aquel velo era el velo de los sueños, de los
dulces sueños que hacen ver la vida de color de rosa. Y con él envolvió a
los cuatro hombres flacos, barbudos e impertinentes. Los cuales cesaron de
estar tristes, porque penetró en ellos la esperanza, y en su cabeza el sol
alegre, con el diablillo de la vanidad, que consuela en sus profundas
decepciones a los pobres artistas.»
Hay en el libro otros varios cuentos, delicados y graciosos, donde se
notan las mismas calidades. Todos estos cuentos parecen escritos en París.
Voy a terminar hablando de los más transcendentales: El rubí y la
canción del oro. El químico Fremy ha descubierto, o se jacta de haber
descubierto, la manera de hacer rubíes. Uno de los gnomos roba uno de esos
rubíes artificiales del medallón que pende del cuello de cierta cortesana, y le
lleva a la extensa y profunda caverna donde los gnomos se reúnen en
conciliábulo. Las fuerzas vivas y creadoras de la Naturaleza, la infatigable
inexhausta fecundidad del alma tierra, están simbolizadas en aquellos
activos y poderosos enanillos que se burlan del sabio y demuestran la
falsedad de su obra. «La piedra es falsa, dicen todos: obra de hombre, o de
sabio, que es peor.»
Luego cuenta el gnomo más viejo la creación del verdadero primer rubí.
Es un hermoso mito, que redunda en alabanza de Amor y de la madre
Tierra, «de cuyo vientre moreno brota la savia de los troncos robustos, y el
oro y el agua diamantina y la casta flor de lis: lo puro, lo fuerte, lo
infalsificable. Y los gnomos tejen una danza frenética y celebran una orgía
sagrada, ensalzando a la mujer, de quien suelen enamorarse, porque es
espíritu de carne: toda amor.»
La canción del oro, sería el mejor de los cuentos de usted si fuera
cuento, y sería el más elocuente de todos si no emplease en él demasiado
una ficelle, de que se usa y de que se abusa muchísimo en el día.
En la calle de los palacios, donde todo es esplendor y opulencia, donde
se ven llegar a sus moradas, de vuelta de festines y bailes, a las hermosas
mujeres y a los hombres ricos, hay un mendigo extraño, hambriento,
tiritando de frío, mal cubierto de harapos. Este mendigo tira un mordisco a
un pequeño mendrugo de pan bazo: se inspira y canta la canción del oro.
Todo el sarcasmo, todo el furor, toda la codicia, todo el amor desdeñado,
todos los amargos celos, toda la envidia que el oro engendra en los
corazones de los hambrientos, de los menesterosos y de los descamisados y
perdidos, están expresados en aquel himno en prosa.
Por esto afirmo que sería admirable la canción del oro si se viese menos
la ficelle: el método o traza de la composición, que tanto siguen ahora los
prosistas, los poetas y los oradores.
El método es crear algo por superposición o aglutinación, y no por
organismo.
El símil es la base de este método. Sencillo es no mentar nada sin símil;
todo es como algo. Luego se ha visto que salen de esta manera muchísimos
comos, y en vez de los comos se han empleado los eses y las esas. Ejemplo:
la tierra: esa madre fecunda de todos los vivientes; el aire, ese manto azul
que envuelve el seno de la tierra, y cuyos flecos son las nubes; el cielo, ese
campo sin límites por donde giran las estrellas, etcétera. De este modo es
fácil llenar mucho papel. A veces los eses y las esas se suprimen, aunque es
menos enfático y menos francés, y sólo se dice el pájaro, flor del aire; la
luna, lámpara nocturna, hostia que se eleva en el templo del espacio, etc.
Y por último, para dar al discurso más animación y movimiento, se ha
discurrido hacer enumeración de todo aquello que se semeja en algo al
objeto de que queremos hablar. Y terminada la enumeración, o cansado el
autor de enumerar, pues no hay otra razón para que termine, dice: eso soy
yo; eso es la poesía; eso es la crítica; eso es la mujer, etc. Puede también el
autor, para prestar mayor variedad y complicación a su obra, decir lo que no
es el objeto que describe antes de decir lo que es. Y puede decir lo que no es
como quien pregunta. Fórmula: ¿Será esto, será aquello, será lo de más
allá? No; no es nada de eso. Luego... la retahila de cosas que se ocurran. Y
por remate: eso es.
Este género de retórica es natural, y todos la empleamos. No se critica
aquí el uso, sino el abuso. En el abuso hay algo parecido al juego infantil de
apurar una letra. «Ha venido un barco cargado de...» Y se va diciendo (si, v.
gr., la letra es b) de baños, de buzos, de bolos, de berros, de bromas.
Las composiciones escritas según este método retórico tienen la ventaja
de que se pueden acortar y alargar ad libitum, y de que se pueden leer al
revés lo mismo que al derecho, sin que a penas varíe el sentido.
En mis peregrinaciones por países extranjeros, y harto lejos de aquí,
conocí yo y traté a una señora muy entendida, cuyo marido era poeta; y ella
había descubierto en los versos de su marido que todos se leían y hacían
sentido empezando por el último verso y acabando por el primero. Querían
decir algunos maldicientes que ella había hecho el descubrimiento para
burlarse de los versos de la cosecha de casa; pero yo siempre tuve por
seguro que ella, cegada por el amor conyugal, ponía en este sentido
indestructible, léanse las composiciones como quiera que se lean, un primor
raro que realzaba el mérito de ellas.
Me ha corroborado en esta opinión un reciente escrito de don Adolfo de
Castro, quien descubre y aplaude en algunos versos de Santa Teresa, casi
como don celeste o gracia divina, esa prenda de que se lean al revés y al
derecho, resultando idéntico sentido.
La verdad del caso, considerado y ponderado todo con imparcial
circunspección, es que tal modo retórico es ridículo cuando se toma por
muletilla, o sirve de pauta para escribir; pero si es espontáneo, está muy
bien: es el lenguaje propio de la pasión.
Figurémonos a una madre, joven, linda y apasionada, con un niño rubito
y gordito y sonrosado, de dos años, que está en sus brazos. Mientras ella le
brinca y él le sonríe, ella le dirá natural y sencillamente interminable lista
de nombres, de objetos, algunos de ellos disparatados. Le llamará ángel,
diablillo, mono, gatito, chuchumeco, corazón, alma, vida, hechizo, regalo,
rey, príncipe y mil cosas más. Y todo estará bien, y nos parecerá encantador,
sea el que sea el orden en que se ponga. Pues lo mismo puede ser toda
composición, en prosa o en verso, por el estilo con tal que no sea buscado ni
frecuente este modo de componer.
El modelo más egregio del género, el ejemplar arquetipo, es la letanía.
La virgen es puerta del cielo, estrella de la mañana, torre de David, arca de
la alianza, casa de oro, y mil cosas más en el orden que se nos antoje
decirlas.
La canción del oro es así: es una letanía, sólo que es infernal en vez de
ser célica. Es por el gusto de la letanía que Baudelaire compuso al demonio;
pero, conviniendo ya en que La canción del oro es letanía, y letanía
infernal, yo me complazco en sostener que es de las más poéticas, ricas y
enérgicas que he leído. Aquello es un diluvio de imágenes, un desfilar
tumultuoso de cuanto hay, para que encomie el oro y predique sus
excelencias.
Citar algo es destruir el efecto que está en la abundancia de cosas que en
desorden se citan y acuden a cantar el oro, «misterioso y callado en las
entrañas de la tierra, y bullicioso cuando brota a pleno sol y a toda vida;
sonante como coro de tímpanos, feto de astros, residuo de luz, encarnación
de éter; hecho de sol, se enamora de la noche, y, al darle el último beso,
riega su túnica con estrellas como con gran muchedumbre de libras
esterlinas. Despreciado por Jerónimo, arrojado por Antonio, vilipendiado
por Macario, humillado por Hilarión, es carne de ídolo, dios becerro, tela de
que Fidias hace el traje de Minerva. De él son las cuerdas de la lira, las
cabelleras de las más tiernas amadas, los granos de la espiga, y el peplo que
al levantarse viste la olímpica aurora.»
Me había propuesto no citar nada, y he citado algo, aunque poco. La
composición es una letanía inorgánica, y, sin embargo, ni la ironía, ni el
amor y el odio, ni el deseo y el desprecio simultáneos que el oro inspira al
poeta en la inopia (achaque crónico y epidémico de los poetas), resaltan
bien sino de la plenitud de cosas que dice del oro, y que se suprimen aquí
por amor a la brevedad.
En resolución, su librito de usted, titulado Azul... nos revela en usted a
un prosista y a un poeta de talento.
Con el galicismo mental de usted no he sido sólo indulgente, sino que le
he aplaudido por lo perfecto. Con todo, yo aplaudiría muchísimo más, si
con esa ilustración francesa que en usted hay, se combinasen la inglesa, la
alemana, la italiana, y ¿por qué no la española también? Al cabo el árbol de
nuestra ciencia no ha envejecido tanto que aun no pueda prestar jugo, ni sus
ramas son tan cortas ni están tan secas que no puedan retoñar como
mugrones del otro lado del Atlántico. De todos modos, con la superior
riqueza y con la mayor variedad de elementos, saldría de su cerebro de
usted algo menos exclusivo y con más altos, puros y serenos ideales: algo
más azul que el azul de su libro de usted; algo que tirase menos a lo verde y
a lo negro. Y por cima de todo, se mostrarían más claras y más marcadas la
originalidad de usted y su individualidad de escritor.
Juan Valera
(De la Real Academia Española).
(CANTO ALEGRE)
(CUENTO GRIEGO)
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.
ebookultra.com