SlideShare a Scribd company logo
Programming With Java Edet Theophilus download
https://ebookbell.com/product/programming-with-java-edet-
theophilus-55229942
Explore and download more ebooks at ebookbell.com
Here are some recommended products that we believe you will be
interested in. You can click the link to download.
Programming With Java A Primer 3e 3rd E Balaguruswamy
https://ebookbell.com/product/programming-with-java-a-primer-3e-3rd-e-
balaguruswamy-34093360
Programming With Java A Primer 3rd Edition E Balagurusamy
https://ebookbell.com/product/programming-with-java-a-primer-3rd-
edition-e-balagurusamy-5411388
Beginning Programming With Java For Dummies 6th Barry Burd
https://ebookbell.com/product/beginning-programming-with-java-for-
dummies-6th-barry-burd-47641808
Soap Programming With Java William B Brogden Bill Brogden
https://ebookbell.com/product/soap-programming-with-java-william-b-
brogden-bill-brogden-2169302
Beginning Programming With Java For Dummies Third Edition 3rd Edition
Barry Burd
https://ebookbell.com/product/beginning-programming-with-java-for-
dummies-third-edition-3rd-edition-barry-burd-22628250
Beginning Programming With Java For Dummies Second Edition 2nd Edition
Barry A Burd
https://ebookbell.com/product/beginning-programming-with-java-for-
dummies-second-edition-2nd-edition-barry-a-burd-33312102
Beginning Programming With Java For Dummies Fourth Edition 4th Barry A
Burd
https://ebookbell.com/product/beginning-programming-with-java-for-
dummies-fourth-edition-4th-barry-a-burd-4924178
Beginning Programming With Java For Dummies 5th Barry Burd
https://ebookbell.com/product/beginning-programming-with-java-for-
dummies-5th-barry-burd-6723376
Reactive Programming With Java 9 Build Asynchronous Applications With
Rxjava 20 Flow Api And Spring Webflux Tejaswini Mandar Jog
https://ebookbell.com/product/reactive-programming-with-java-9-build-
asynchronous-applications-with-rxjava-20-flow-api-and-spring-webflux-
tejaswini-mandar-jog-6865226
Download full ebook of Programming With Java Edet Theophilus instant download pdf
Download full ebook of Programming With Java Edet Theophilus instant download pdf
Programming With Java
By Theophilus Edet
Theophilus Edet
theoedet@yahoo.com
facebook.com/theoedet
twitter.com/TheophilusEdet
Instagram.com/edettheophilus
Copyright © 2023 Theophilus Edet All rights reserved.
No part of this publication may be reproduced, distributed, or transmitted in any form or by any
means, including photocopying, recording, or other electronic or mechanical methods, without the
prior written permission of the publisher, except in the case of brief quotations embodied in reviews
and certain other non-commercial uses permitted by copyright law.
Table of Contents
Preface
Programming With Java
Module 1: Introduction to Java Programming
What is Java and its Significance
Installing and Setting Up Java Development Environment
Writing Your First Java Program
Understanding the Java Virtual Machine (JVM)
Module 2: Variables and Data Types in Java
Declaring and Initializing Variables
Java's Primitive Data Types: int, float, boolean, etc.
Type Casting and Conversion in Java
Variable Scope and Lifetime in Java
Module 3: Basic Input and Output in Java
Using System.out.println and System.out.print for Output
Reading User Input with Scanner Class
Formatting Output with printf
Debugging Techniques in Java
Module 4: Operators and Expressions in Java
Arithmetic, Relational, and Logical Operators
Operator Precedence and Associativity
Using Operators for Expressions in Java
Bitwise Operators and Manipulation
Module 5: Control Flow and Conditional Statements
Using if, else, and else if Statements
Ternary Operator for Conditional Expressions
Switch Statements for Multiple Choices
Handling Conditions and Creating Logical Flows
Module 6: Loops and Iteration in Java
while and do-while Loops for Iteration
Using for Loop for Controlled Iteration
Loop Control: break, continue, and return
Iterating Over Arrays and Collections
Module 7: Arrays and Array Manipulation in Java
Creating and Manipulating Arrays
Accessing and Modifying Array Elements
Array Methods: length, clone, Arrays class
Multi-Dimensional Arrays and Nested Arrays
Module 8: Introduction to Functions in Java
Writing and Defining Methods in Java
Method Parameters and Return Values
Method Overloading and Variadic Methods
Scoping and Method Call Stack in Java
Module 9: Control Structures and Flow Control in Java
Applying Control Structures: if-else, switch
Using for and while Loops
The Enhanced for Loop and Iterators
Applying Flow Control Techniques in Java
Module 10: Strings and String Manipulation in Java
Creating and Manipulating Strings
String Concatenation and Formatting
String Methods: charAt, substring, length
String Equality and Comparison in Java
Module 11: Introduction to Object-Oriented Programming (OOP)
Understanding OOP Concepts: Abstraction, Encapsulation, Inheritance, Polymorphism
Creating Classes and Objects in Java
Defining Attributes and Methods in Classes
Access Modifiers and Encapsulation in Java
Module 12: Methods and Constructors in Java
Writing Methods in Java
Method Overloading and Method Signature
Constructors and Constructor Overloading
Using this and Constructor Chaining
Module 13: Class Relationships and Inheritance in Java
Understanding Inheritance in Java
Creating Subclasses and Superclasses
Method Overriding and @Override Annotation
Polymorphism and Dynamic Method Dispatch
Module 14: Access Modifiers and Encapsulation in Java
Public, Protected, Default, and Private Access Modifiers
Encapsulation and Data Hiding in Java
Getter and Setter Methods
Best Practices for Access Modifiers
Module 15: Abstract Classes and Interfaces in Java
Declaring and Defining Abstract Classes
Implementing Interfaces in Java
Multiple Inheritance with Interfaces
When to Use Abstract Classes vs. Interfaces
Module 16: Exception Handling and Error Management in Java
Introduction to Exception Handling
Using try, catch, and finally Blocks
Throwing and Catching Exceptions
Creating Custom Exception Classes
Module 17: Introduction to Collections Framework in Java
Overview of Java Collections Framework
Working with ArrayList and LinkedList
Using HashSet, LinkedHashSet, and TreeSet
Collections Algorithms and Sorting
Module 18: Lists, Sets, and Maps in Java
Working with List Interface: ArrayList and LinkedList
Using Set Interface: HashSet, LinkedHashSet, and TreeSet
Understanding Map Interface: HashMap, LinkedHashMap, and TreeMap
Iterating and Manipulating Collections
Module 19: Generics and Type-Safe Collections in Java
Introduction to Generics in Java
Writing Generic Classes and Methods
Using Generic Collections: List<E>, Set<E>, Map<K,V>
Type Erasure and Wildcards
Module 20: Introduction to Threads and Concurrency in Java
Understanding Threads and Multithreading
Creating Threads with Thread Class and Runnable Interface
Thread States and Synchronization
Thread Safety and Race Conditions
Module 21: Synchronization and Locks in Java
Understanding Synchronization and Critical Sections
Using synchronized Keyword
Using Locks: ReentrantLock and ReadWriteLock
Deadlocks and Avoiding Race Conditions
Module 22: Introduction to Input/Output (I/O) in Java
File I/O Basics: Reading and Writing Files
Using File and FileWriter/FileReader Classes
Byte Streams and Character Streams
Using BufferedReader and BufferedWriter
Module 23: Networking and Socket Programming in Java
Introduction to Networking in Java
Creating TCP and UDP Sockets
Implementing Server and Client Applications
Handling Network Errors and Exceptions
Module 24: Introduction to GUI Programming with Swing
Building Graphical User Interfaces (GUIs) in Java
Creating GUI Components: JFrame, JPanel, JButton
Event Handling and Listener Interfaces
Layout Managers and Designing Uis
Module 25: Working with GUI Components and Layouts
Using Text Components: JTextField, JTextArea
Creating Lists, Tables, and Combo Boxes
Using Layout Managers: FlowLayout, BorderLayout, GridLayout
Building Complex UIs and Windows
Module 26: File Handling and Serialization in Java
Serialization and Deserialization Concepts
Implementing Serialization with Serializable Interface
Writing and Reading Objects to/from Files
Handling Object Versioning and Compatibility
Module 27: Introduction to JavaFX for Modern UI Development
Introduction to JavaFX Framework
Building UI with Scene Graph and Nodes
Using CSS for Styling JavaFX Applications
Creating Animation and Transitions
Module 28: Database Connectivity with JDBC
Introduction to JDBC (Java Database Connectivity)
Connecting to Databases with DriverManager
Executing SQL Queries and Statements
Handling ResultSets and Performing CRUD Operations
Module 29: Java Collections Framework in Depth
Deeper Dive into Collections Framework
Working with Queue Interface and Implementations
Using Map Interface and Advanced Map Operations
Java Streams API and Functional Programming
Module 30: Building Java Applications and Final Project
Structuring a Java Project: Packages and Modules
Implementing a Java Application
Testing and Debugging Java Applications
Building a Final Project and Creating a Portfolio
Review Request
Embark on a Journey of ICT Mastery with CompreQuest Books
Preface
Welcome to "Programming With Java," a comprehensive
guide designed to empower both novice and seasoned
developers on their journey through the dynamic realm of Java
programming. In this preface, we embark on a journey to explore the
paradigms, programming models, and diverse applications that make Java a
powerhouse in the world of software development.
Java: A Versatile and Ubiquitous Programming Language
Java, since its inception by Sun Microsystems in the mid-1990s, has stood
the test of time as a versatile, platform-independent, and widely adopted
programming language. Its ability to run on diverse platforms without
modification, thanks to the "Write Once, Run Anywhere" (WORA)
philosophy, has made it a staple in a multitude of domains, from web
development to enterprise solutions.
Object-Oriented Paradigm: The Foundation of Java's Power
At the heart of Java's elegance is its commitment to the object-oriented
paradigm. By embracing encapsulation, inheritance, and polymorphism,
Java provides developers with a robust and modular structure for building
scalable and maintainable software. This paradigm encourages code
reusability, fosters modular design, and enables the construction of complex
systems through the composition of well-defined objects.
Procedural and Functional Programming: Expanding the Toolkit
While rooted in object-oriented principles, Java is not confined to a single
paradigm. It seamlessly integrates procedural and functional programming
features, offering developers the flexibility to choose the paradigm that best
suits their problem-solving needs. This versatility allows for the
development of concise, expressive code, further enhancing Java's appeal
across various application domains.
Key Programming Models Supported by Java
"Programming With Java" unfolds with an exploration of the core
programming models that Java supports:
1. Application Programming: Java excels in building standalone
applications, ranging from desktop utilities to complex
enterprise solutions. The language's extensive standard library,
coupled with powerful development frameworks, empowers
developers to create robust and feature-rich applications.
2. Web Development: Java has left an indelible mark on web
development, with frameworks like Spring and JavaServer
Faces (JSF) facilitating the creation of scalable and
maintainable web applications. The ability to build dynamic
and interactive web interfaces has made Java a preferred choice
for enterprises and startups alike.
3. Mobile Development: Through platforms like Android, Java
has become synonymous with mobile application development.
The Android SDK leverages Java's capabilities, enabling
developers to craft innovative and resource-efficient mobile
applications for a global audience.
4. Enterprise Solutions: Java's prowess in developing enterprise-
level solutions is showcased through technologies like Java EE
(Enterprise Edition). This model provides a robust
infrastructure for building scalable and distributed systems,
making it a go-to choice for large-scale applications.
5. Cloud Computing: Java's compatibility with cloud computing
platforms and frameworks, such as Spring Cloud, positions it
as a formidable player in the era of cloud-native applications.
Java's ability to seamlessly integrate with cloud services
enhances its relevance in the ever-evolving landscape of cloud
computing.
Applications of Java in the Modern World
The subsequent chapters of this book delve into real-world applications of
Java across diverse industries. From financial services and healthcare to e-
commerce and game development, Java's adaptability shines through. Its
reliability, performance, and the vast ecosystem of libraries and frameworks
contribute to its sustained popularity in mission-critical applications.
Navigating "Programming With Java"
"Programming With Java" is crafted with a pedagogical approach, ensuring
that readers, whether beginners or experienced developers in other
languages, can seamlessly grasp Java's intricacies. The book adopts a
structured progression, beginning with fundamental concepts, progressing
through advanced topics, and culminating in the development of a final
project.
As you embark on this educational journey, embrace the challenges and
discoveries that come with mastering Java. Whether you're aiming to build
enterprise-level applications, explore mobile development, or contribute to
the vibrant world of open-source projects, "Programming With Java" serves
as your compass, guiding you through the diverse landscape of Java
programming.
Let the exploration begin!
Theophilus Edet
Programming With Java
In the dynamic landscape of computer programming, Java stands as a
stalwart language, renowned for its versatility, portability, and extensive
applications across a myriad of domains. "Programming With Java" serves
as an indispensable guide for both novice and experienced programmers,
offering a comprehensive exploration of Java's intricacies and practical
applications.
Java's Ubiquity in Programming
Java's significance in the programming world cannot be overstated. Born
out of the vision to create a platform-independent language, Java has
become ubiquitous in various software ecosystems. Its "write once, run
anywhere" philosophy has empowered developers to create applications that
seamlessly run on diverse platforms, from embedded systems to enterprise
servers. The book navigates through Java's evolution, delving into its
historical roots and tracing the journey that has made it a cornerstone in
modern software development.
Applications Across Industries
"Programming With Java" unravels the myriad applications of Java across
industries, showcasing its adaptability and robustness. From mobile
application development with Android to web-based solutions and
enterprise-level systems, Java's versatility makes it a go-to choice for
developers addressing diverse challenges. The book provides real-world
examples and case studies, illustrating how Java serves as the backbone for
crafting solutions that power the digital realm.
Programming Models and Paradigms
Java accommodates a spectrum of programming models and paradigms,
making it a language of choice for developers with varying preferences and
project requirements. The book delves into object-oriented programming
(OOP), emphasizing Java's robust support for encapsulation, inheritance,
and polymorphism. It explores the concurrent programming capabilities of
Java, showcasing how developers can harness threads and concurrency
utilities to build responsive and efficient applications.
Java's Support for Modern Development Practices
As the programming landscape continues to evolve, "Programming With
Java" addresses Java's embrace of modern development practices. The book
explores Java's compatibility with functional programming, introducing
readers to lambda expressions and the Stream API. It highlights Java's role
in supporting modular programming through the introduction of the Java
Platform Module System (JPMS), enabling developers to create scalable
and maintainable codebases.
In conclusion, "Programming With Java" serves as an invaluable
companion for those embarking on a journey into Java programming or
seeking to deepen their understanding of this powerful language. Through
its exploration of applications, programming models, and paradigms, the
book equips readers with the knowledge to leverage Java's capabilities in
crafting robust and innovative software solutions. Whether a novice or an
experienced developer, this book is a gateway to mastering Java and
unleashing its potential in the ever-evolving world of programming.
Module 1:
Introduction to Java Programming
Within the broader context of "Programming With Java," the module titled
"Introduction to Java Programming" serves as the foundational cornerstone,
providing readers with a comprehensive initiation into the world of Java.
This module is meticulously designed to cater to learners at various levels
of expertise, offering a structured approach to understanding Java's syntax,
concepts, and fundamental principles.
Navigating the Java Landscape
The module commences by guiding readers through an exploration of the
Java programming language's landscape. It elucidates the historical context
of Java, tracing its origins and evolution. By understanding the language's
inception, readers gain insights into the design principles that have shaped
Java into the versatile and widely adopted programming language it is
today. This historical perspective sets the stage for a deeper dive into the
technical aspects of Java programming.
Grasping Java Syntax and Structure
"Introduction to Java Programming" places a strong emphasis on
demystifying Java's syntax and structure. The module systematically
introduces key programming constructs, such as variables, data types,
control flow statements, and functions. Through clear explanations and
illustrative examples, readers are equipped with the essential building
blocks to write simple yet effective Java programs. The module lays the
groundwork for a solid understanding of the language's core elements,
preparing learners for more advanced concepts.
Object-Oriented Programming Principles
Central to Java's identity is its strong adherence to object-oriented
programming (OOP) principles. This module delves into the heart of OOP,
unraveling concepts like classes, objects, inheritance, encapsulation, and
polymorphism. Through hands-on exercises and practical examples, readers
not only comprehend the theoretical underpinnings of OOP but also
develop the skills to apply these principles in crafting efficient and
maintainable Java code.
Hands-On Learning with Java Exercises
"Introduction to Java Programming" adopts a hands-on learning approach,
recognizing the importance of practical application in reinforcing
theoretical knowledge. The module is interspersed with coding exercises
and challenges that encourage readers to actively engage with the material.
These exercises serve as opportunities to implement newfound knowledge,
solidify understanding, and cultivate problem-solving skills—a crucial
aspect of becoming proficient in Java programming.
Building a Foundation for Advanced Concepts
Beyond laying the groundwork for Java basics, this module aspires to instill
a sense of confidence in learners, setting the stage for more advanced topics
covered in subsequent sections of the book. By the module's conclusion,
readers are equipped with the requisite skills to embark on the journey of
exploring Java's diverse applications, programming models, and paradigms,
as outlined in the broader context of "Programming With Java."
What is Java and its Significance
The "What is Java and its Significance?" section within the
"Introduction to Java Programming" module of "Programming With
Java" initiates readers into the fundamental nature and pivotal role of
Java in the programming realm. Java, characterized as a high-level,
object-oriented programming language, serves as a robust platform
for developers to construct a diverse array of applications. Its
crowning feature, the "write once, run anywhere" capability, signifies
that Java code, once compiled, can execute seamlessly on any device
boasting a Java Virtual Machine (JVM). This intrinsic quality has
significantly propelled Java's widespread adoption, cementing its
importance in various computing environments.
Java Syntax Demystified
A thorough understanding of Java's syntax forms the crux of this
section, unraveling the language's fundamental building blocks. For
instance, variable declarations in Java echo a familiar syntax:
// Java Syntax
int myNumber = 42;
String greeting = "Hello, Java!";
By delving into such code snippets, readers gain a hands-on
appreciation of Java's syntax, providing a solid foundation for
subsequent programming endeavors. This approach aims to
demystify the intricacies of Java for learners, especially those
transitioning from other languages, making the assimilation of
concepts more accessible.
Platform Independence: Java's Distinct Paradigm
Integral to Java's significance is its unique approach to achieving
platform independence. The section elucidates the process whereby
Java source code undergoes compilation into bytecode, a platform-
neutral intermediate representation. This bytecode is then executed
by the Java Virtual Machine (JVM), allowing Java applications to
transcend platform constraints effortlessly. The paradigm of platform
independence positions Java as a language capable of running on
diverse devices without modification. Such adaptability has solidified
Java's role in the development of mobile applications, web services,
and scalable enterprise-level systems.
Versatility and Ecosystem Strength
The significance of Java extends beyond syntax and platform
independence to encompass its versatile ecosystem. Readers are
introduced to the myriad applications of Java, ranging from Android
application development to server-side programming. The section
navigates through Java's robust libraries, frameworks, and vibrant
community, illustrating how these elements collectively contribute to
the language's adaptability in an ever-evolving technological
landscape. Java's versatility is underscored by its resilience and
enduring relevance, making it a cornerstone for programmers
globally as they explore the multifaceted realms of software
development.
Installing and Setting Up Java Development Environment
In the "Introduction to Java Programming" module of "Programming
With Java," the section dedicated to "Installing and Setting Up Java
Development Environment" serves as the gateway for readers to
actively engage with Java programming. This essential phase
involves preparing the development environment, ensuring a
seamless transition from theory to practical application.
Downloading and Installing the Java Development Kit (JDK)
The first step in embarking on the Java programming journey is to
download and install the Java Development Kit (JDK). The book
guides readers through this process, emphasizing the importance of
choosing the appropriate JDK version for their specific development
needs. A typical Java installation involves setting system variables,
such as JAVA_HOME and PATH, to enable the system to locate the
Java binaries.
// Setting JAVA_HOME and PATH in a bash environment (Linux/macOS)
export JAVA_HOME=/path/to/your/jdk
export PATH=$JAVA_HOME/bin:$PATH
Such details provide readers with a practical understanding of the
configuration steps, ensuring they can seamlessly set up their
development environment.
Configuring Integrated Development Environment (IDE)
The section goes on to explore the advantages of using Integrated
Development Environments (IDEs) for Java development. Popular
IDEs like Eclipse or IntelliJ IDEA streamline the development
process with features such as code completion, debugging tools, and
project management. The book offers step-by-step instructions on
installing and configuring these IDEs, empowering readers to choose
the environment that aligns with their preferences and workflow.
// Configuring Eclipse IDE with JDK
1. Open Eclipse
2. Navigate to Window > Preferences > Java > Installed JREs
3. Add the JDK installation path
4. Set the added JDK as the default JRE for the workspace
By delving into the specifics of IDE configuration, the book ensures
that readers not only install Java but also optimize their development
environment for efficiency and productivity.
Verifying the Java Installation
To validate the successful setup of the Java development
environment, the section concludes with instructions on verifying the
Java installation. Readers are guided on executing a simple Java
program—perhaps the ubiquitous "Hello, World!"—to confirm that
the JDK and IDE configurations are accurate.
// Hello, World! in Java
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
Through hands-on verification, readers gain confidence in their
environment, laying the groundwork for the practical exercises and
programming challenges that lie ahead in the comprehensive
"Programming With Java" curriculum.
Configuring Visual Studio Code for Java Development
In addition to traditional IDEs, many developers opt for Visual Studio
Code due to its lightweight yet powerful features and extensive
extensions. The section provides guidance on installing the necessary
extensions for Java development in VS Code.
// Installing Java Extension Pack in Visual Studio Code
1. Open VS Code
2. Navigate to Extensions (or use shortcut Ctrl+Shift+X)
3. Search for "Java Extension Pack"
4. Click "Install" to install the pack, which includes essential
extensions for Java development.
This extension pack includes features like language support,
debugging tools, and Maven integration, enriching the VS Code
environment for Java programming.
Configuring Build Tools: Maven or Gradle
For a more comprehensive Java development environment, the book
addresses the configuration of build tools such as Maven or Gradle.
These tools simplify project management, dependency resolution,
and build processes. Here's an example of configuring Maven within
VS Code:
// Configuring Maven in Visual Studio Code
1. Install the "Maven for Java" extension.
2. Open a Java project with a `pom.xml` file.
3. VS Code will prompt to import the Maven project. Click
"Import Changes."
By incorporating these details, readers gain insights into configuring
a diverse set of tools within Visual Studio Code, tailoring their
environment to their preferred workflows.
Running Java Programs in VS Code
The section concludes by demonstrating how to run Java programs
directly from Visual Studio Code. It guides readers on configuring
run and debug configurations, ensuring a seamless experience when
executing Java code within the VS Code environment.
// Running Java Programs in Visual Studio Code
1. Open a Java file.
2. Right-click and select "Run" or "Debug" based on the
desired configuration.
By including VS Code in the discussion, the book acknowledges the
diverse preferences within the Java development community,
ensuring that readers can choose an environment that best suits their
needs and workflow. This comprehensive approach prepares them for
a holistic Java programming experience, whether using traditional
IDEs or lightweight editors like Visual Studio Code.
Writing Your First Java Program
The pivotal moment of transitioning from theory to practical
application unfolds in the "Writing Your First Java Program" section
within the "Introduction to Java Programming" module of
"Programming With Java." This section is designed to empower
readers with the foundational skills needed to create and execute a
simple Java program. It serves as a hands-on initiation into the syntax
and structure of Java code, establishing a solid base for more
complex programming tasks.
Creating a Simple Java Class
The journey begins by guiding readers through the process of
creating a simple Java class. In Java, a class serves as the blueprint
for objects, encapsulating data and behavior. The book introduces the
essential components of a Java class, starting with the class
declaration.
// Java Class Declaration
public class MyFirstProgram {
// Class body goes here
}
By breaking down the syntax, readers grasp the significance of the
public class declaration, laying the groundwork for a deeper
understanding of Java's object-oriented nature.
Adding the Main Method for Execution
The heart of any Java program lies within the main method. This
method acts as the entry point for the program, specifying the code to
be executed when the program runs. The book elucidates the
structure of the main method and its importance.
// Main Method Declaration
public class MyFirstProgram {
public static void main(String[] args) {
// Code to be executed goes here
}
}
This snippet provides readers with a clear delineation of the main
method, emphasizing the necessity of its signature for program
execution.
Printing "Hello, Java!" to the Console
The section culminates in the execution of a quintessential "Hello,
World!" program. By using the System.out.println statement, readers
learn how to output text to the console, a fundamental aspect of Java
programming.
// Hello, World! Program
public class MyFirstProgram {
public static void main(String[] args) {
System.out.println("Hello, Java!");
}
}
Through this illustrative example, readers witness the practical
application of Java syntax, witnessing the tangible output of their first
Java program.
Compiling and Running the Java Program
Completing the journey, the section walks readers through the
compilation and execution process. It introduces the javac compiler
for Java source code and the java command for running the compiled
program.
# Compile Java Program
javac MyFirstProgram.java
# Run Java Program
java MyFirstProgram
By including these steps, the book ensures that readers not only write
Java code but also gain proficiency in the essential tasks of compiling
and executing their programs. This section, therefore, serves as a
pivotal stepping stone in the practical application of Java
programming concepts within the broader framework of
"Programming With Java."
Understanding the Java Virtual Machine (JVM)
Within the "Introduction to Java Programming" module of
"Programming With Java," the section dedicated to "Understanding
the Java Virtual Machine (JVM)" unveils the core mechanism that
makes Java a platform-independent language. This section delves
into the inner workings of the JVM, shedding light on how it
interprets and executes Java bytecode, providing a crucial bridge
between Java's source code and the underlying hardware.
Overview of the JVM Architecture
The journey begins with an exploration of the JVM architecture,
elucidating its key components and their roles. Readers are
introduced to the classloader, responsible for loading Java classes
into memory, the bytecode verifier ensuring code integrity, the Just-
In-Time (JIT) compiler optimizing performance, and the execution
engine translating bytecode into machine code. This multifaceted
architecture underpins Java's ability to run on diverse platforms
without modification.
// Sample Java Class
public class SampleClass {
public void printMessage() {
System.out.println("This is a sample message.");
}
}
By breaking down the Java class into its bytecode representation,
readers gain insight into the intermediary stage that facilitates
platform independence.
Class Loading and Execution Flow
The section navigates through the class-loading process,
demystifying how the JVM locates, loads, and links classes during
program execution. The book provides a comprehensive overview of
the class initialization sequence and the role of the ClassLoader in
dynamically loading classes into the Java runtime environment.
// Class Loading in Java
public class MyClass {
public static void main(String[] args) {
SampleClass sample = new SampleClass();
sample.printMessage();
}
}
By dissecting the execution flow, readers gain a profound
understanding of how the JVM manages classes and their
dependencies during runtime.
Bytecode Verification and JIT Compilation
To ensure the security and integrity of Java programs, the section
delves into bytecode verification, an essential step in the class-
loading process. Readers discover how the JVM meticulously
examines bytecode for adherence to Java language specifications,
preventing runtime errors and potential security vulnerabilities. The
discussion extends to the JIT compilation process, where bytecode is
translated into native machine code for enhanced performance.
// JIT Compilation in Action
public class PerformanceExample {
public static void main(String[] args) {
// Code triggering JIT compilation
for (int i = 0; i < 1000; i++) {
System.out.println("Executing code for JIT compilation.");
}
}
}
By illustrating the connection between code execution patterns and
JIT compilation, readers gain insights into optimizing Java programs
for runtime efficiency.
Memory Management and Garbage Collection
Concluding the section, readers delve into memory management and
garbage collection within the JVM. The book demystifies how the
JVM handles memory allocation and automatic garbage collection,
ensuring efficient resource utilization and preventing memory leaks.
// Memory Management in Java
public class MemoryExample {
public static void main(String[] args) {
// Code demonstrating memory allocation and usage
int[] numbers = new int[1000];
// ...
}
}
Through these examples, the section unravels the intricacies of the
JVM's role in managing memory, providing readers with a
comprehensive understanding of the Java runtime environment. This
foundational knowledge equips them to write efficient and reliable
Java programs as they progress through the "Programming With
Java" curriculum.
Module 2:
Variables and Data Types in Java
In the dynamic world of programming, understanding the fundamentals of
variables and data types is akin to mastering the alphabet before crafting
intricate prose. The module "Variables and Data Types in Java" within the
book "Programming With Java" is a foundational exploration that propels
readers into the heart of Java programming. This module serves as a
stepping stone for both novice and experienced programmers, laying the
groundwork for robust and efficient code construction by unraveling the
nuances of variables and data types in the Java language.
The Significance of Variables in Java
The module commences by demystifying the concept of variables, which
are essential placeholders for storing and manipulating data in a program.
Readers delve into the rules for naming variables, understanding their
scope, and appreciating the dynamic nature of Java's variable declaration.
Through practical examples and exercises, the module ensures that learners
grasp the pivotal role variables play in shaping the flow and logic of a Java
program.
Understanding Data Types: The Building Blocks of Java Programs
A pivotal aspect of programming proficiency lies in comprehending the
diverse data types available in a language. This module meticulously
explores Java's rich assortment of data types, ranging from primitive types
like integers and floating-point numbers to more complex ones such as
arrays and objects. The module elucidates the characteristics and use cases
of each data type, guiding readers in making informed decisions when
choosing the most suitable type for a given scenario.
Declaration and Initialization: Navigating the Java Syntax
Navigating through the intricacies of Java syntax, the module addresses the
process of variable declaration and initialization. Readers learn the syntax
for declaring variables with precision, ensuring that the type and name are
specified appropriately. The module extends to the crucial task of
initializing variables, elucidating how this process sets the initial value for a
variable, a fundamental step in ensuring predictable program behavior.
The Dynamic Nature of Variables in Java
Java's dynamic nature shines through in its support for variables that can
adapt to different data types during runtime. The module explores the
concept of dynamic typing, showcasing how variables can be reassigned to
different types, enhancing flexibility in programming. This dynamic nature
allows Java developers to create versatile and adaptive code structures,
responding dynamically to changing requirements.
Building a Foundation for Advanced Concepts
The "Variables and Data Types in Java" module serves as a cornerstone for
mastering more advanced Java concepts. Armed with a profound
understanding of variables and data types, readers are well-equipped to
explore topics like control flow, methods, and object-oriented programming
in subsequent modules. By providing a comprehensive foundation, this
module ensures that learners are primed to leverage the full power of Java
in crafting efficient, scalable, and maintainable software solutions.
Declaring and Initializing Variables
Within the comprehensive module on "Variables and Data Types in
Java" in the book "Programming With Java," the section dedicated to
"Declaring and Initializing Variables" serves as a crucial foundation
for understanding the dynamic nature of variables in Java. This
section delves into the nuances of variable declaration, exploring how
Java developers define and set the stage for manipulating data within
their programs.
Understanding Variable Declaration in Java
The section commences with a thorough exploration of variable
declaration, a fundamental concept in Java programming. In Java,
declaring a variable involves specifying its type and name. For
instance:
// Variable Declaration in Java
int myNumber;
double pi;
String greeting;
Here, readers are introduced to integer (int), floating-point (double),
and string (String) variables. By breaking down the syntax, the
section ensures that learners comprehend the essential components of
variable declaration and gain familiarity with common data types.
Variable Initialization: Setting Initial Values
Moving beyond declaration, the section navigates into the realm of
variable initialization. Initialization involves assigning an initial value
to a variable, allowing it to hold meaningful data from the outset. For
example:
// Variable Initialization in Java
int myNumber = 42;
double pi = 3.14;
String greeting = "Hello, Java!";
Through these examples, readers witness the synergy between
declaration and initialization, recognizing how this dynamic duo
forms the bedrock of variable usage in Java programs.
Dynamic Typing: Adapting Variables at Runtime
A distinctive feature of Java is its support for dynamic typing,
enabling variables to adapt to different data types during runtime.
The section explores scenarios where the same variable can take on
different forms, fostering adaptability within a program.
// Dynamic Typing in Java
var dynamicVar = 42; // an integer
dynamicVar = 3.14; // now a double
dynamicVar = "Java"; // now a String
Here, the use of the var keyword exemplifies dynamic typing,
allowing the variable to seamlessly transition between integer,
double, and string types.
Scope and Lifetime of Variables
The section delves into the concepts of scope and lifetime,
elucidating how these factors influence a variable's accessibility and
existence within a program. Understanding the scope and lifetime of
variables is pivotal for writing efficient and error-free Java code.
// Scope and Lifetime in Java
public class VariableExample {
public static void main(String[] args) {
int localVar = 10; // Local variable with limited scope
// ...
}
}
By exploring code snippets like this, readers gain insights into how
variables are confined to specific contexts and when they cease to
exist, enhancing their ability to manage and optimize Java programs
effectively.
Conclusion and Building Blocks for Advanced Concepts
The "Declaring and Initializing Variables" section serves as a pivotal
building block within the broader module. By comprehending the
intricacies of variable declaration, initialization, dynamic typing, and
the nuances of scope and lifetime, readers are well-prepared to delve
into more advanced Java concepts. This foundational knowledge
equips learners with the skills necessary to craft sophisticated and
resilient Java programs as they progress through the "Programming
With Java" curriculum.
Java's Primitive Data Types: int, float, boolean, etc.
The cornerstone of effective Java programming lies in understanding
and harnessing its diverse set of primitive data types. The section on
"Java's Primitive Data Types" within the module "Variables and Data
Types in Java" in "Programming With Java" delves into the
intricacies of these fundamental building blocks. Through a detailed
exploration of int, float, boolean, and other essential data types, this
section equips learners with the foundational knowledge to handle a
variety of data in their Java programs.
Integers: The Foundation of Whole Numbers
The section initiates with a close examination of the int data type,
representing whole numbers without decimal points. In Java, the int
data type is used for storing integer values within a specific range.
// int Data Type in Java
int myInteger = 42;
By exploring the syntax and application of int, readers grasp the
significance of this fundamental data type in representing whole
numbers in Java programs.
Floating-Point Numbers: Precision with float and double
Moving beyond integers, the section navigates into the realm of
floating-point numbers using the float and double data types. These
types accommodate values with decimal points, offering varying
levels of precision.
// float and double Data Types in Java
float myFloat = 3.14f;
double myDouble = 3.1415926535;
Through these examples, readers gain insight into the nuances of
choosing between float and double based on the precision
requirements of their Java applications.
Boolean: True or False Values
The discussion extends to the boolean data type, a binary type
representing true or false values. Booleans are fundamental for
decision-making in Java programs, often determining the flow of
control within conditional statements.
// boolean Data Type in Java
boolean isJavaFun = true;
By exploring boolean data types, readers understand their pivotal role
in crafting conditional expressions and logical operations.
Character: Representing Single Characters
The section further explores the char data type, designed for storing
individual characters. This data type is integral for handling letters,
digits, and symbols in Java programs.
// char Data Type in Java
char myChar = 'A';
Through examples like these, learners gain a comprehensive
understanding of the char data type and its application in handling
individual characters.
Byte and Short: Compact Integer Representations
The module delves into the less commonly used but equally
important byte and short data types, providing compact
representations for integer values within specific ranges.
// byte and short Data Types in Java
byte myByte = 127;
short myShort = 32000;
By exploring these data types, readers recognize their utility in
scenarios where memory conservation and efficiency are paramount.
Conclusion: Foundational Knowledge for Data Handling
The "Java's Primitive Data Types" section concludes by emphasizing
the foundational role these data types play in Java programming. By
comprehending the intricacies of int, float, boolean, char, byte, and
short, readers are well-equipped to make informed decisions when
selecting the appropriate data type for handling different kinds of data
in their Java programs. This foundational knowledge sets the stage
for more advanced explorations within the realm of "Programming
With Java."
Type Casting and Conversion in Java
The intricacies of handling data in Java extend beyond the realm of
primitive data types, leading to the necessity of understanding type
casting and conversion. The "Type Casting and Conversion in Java"
section within the "Variables and Data Types in Java" module of
"Programming With Java" unravels the mechanisms by which
developers can manipulate and transform data between different
types. This section is instrumental in empowering learners to
effectively manage data in diverse scenarios, ensuring flexibility and
precision in their Java programs.
Understanding Type Casting
The journey begins with a deep dive into type casting, a process
essential for converting data from one type to another. Java supports
two types of casting: implicit (automatic) casting and explicit
(manual) casting.
// Implicit Casting in Java
int intValue = 42;
double doubleValue = intValue; // Automatic casting from int to double
Here, the integer value is implicitly cast to a double without requiring
explicit intervention. The section elucidates scenarios where implicit
casting occurs seamlessly and how it impacts the precision and range
of data.
Explicit Casting: Precision and Caution
The section transitions to explicit casting, where developers manually
convert data from one type to another. Explicit casting is crucial
when transforming data to a type with a smaller range or lower
precision.
// Explicit Casting in Java
double doubleValue = 3.14;
int intValue = (int) doubleValue; // Manual casting from double to int
Through examples like these, readers understand the importance of
explicit casting in scenarios where precision must be carefully
managed to prevent data loss.
Numeric Promotion: The Hierarchy of Types
The section delves into the concept of numeric promotion, unveiling
the hierarchy of data types in Java. When performing operations
involving different numeric types, Java automatically promotes the
smaller type to the larger type to maintain precision.
// Numeric Promotion in Java
int intValue = 10;
double doubleValue = 3.5;
double result = intValue * doubleValue; // Promotion of int to double for precision
By exploring numeric promotion, readers gain insights into how Java
ensures consistent and accurate results in arithmetic operations
involving different numeric types.
Conversion Between Data Types
Expanding the discussion, the section explores conversion between
data types beyond numeric types. It covers scenarios where data must
be transformed between primitives and objects, emphasizing the
principles of widening and narrowing conversions.
// Conversion Between Data Types in Java
int intValue = 42;
String stringValue = Integer.toString(intValue); // Converting int to String
Through examples like these, readers gain proficiency in converting
data between different types, enabling seamless integration of diverse
data in their Java programs.
Conclusion: Precision, Flexibility, and Best Practices
The "Type Casting and Conversion in Java" section concludes by
emphasizing the significance of precision, flexibility, and adherence
to best practices when dealing with type casting and conversion. This
foundational knowledge equips learners with the tools to manipulate
data effectively in Java, fostering adaptability and precision within
their programming endeavors.
Variable Scope and Lifetime in Java
Navigating the intricate landscape of Java programming involves not
only understanding data types and variable declaration but also
grasping the concepts of variable scope and lifetime. The "Variable
Scope and Lifetime in Java" section within the "Variables and Data
Types in Java" module of "Programming With Java" delves into these
crucial aspects, shedding light on how variables are accessed, where
they exist, and when they cease to exist within a program.
Understanding Variable Scope
The journey begins by dissecting the notion of variable scope, which
defines the region or context in which a variable can be accessed. In
Java, variables can have local scope, method scope, class scope, or
even global scope, each with its own set of rules and implications.
// Local Variable with Method Scope in Java
public class ScopeExample {
public void myMethod() {
int localVar = 42; // Local variable with method scope
// ...
}
}
By exploring the syntax and implications of local scope, readers gain
insight into how variables are confined to specific methods, limiting
their accessibility.
Class Scope: Member Variables and Fields
The section transitions to class scope, where variables become
member variables or fields of a class. These variables exist
throughout the class and are accessible by all methods within the
class.
// Class Scope with Member Variable in Java
public class ScopeExample {
private int classVar; // Class variable with class scope
public void myMethod() {
// Accessing classVar within the method
int result = classVar * 10;
// ...
}
}
Here, the class variable classVar demonstrates class scope, allowing
its use across various methods within the class.
Global Scope: Constants and Beyond
While Java doesn't have truly global variables, constants created
using the final keyword often serve a similar purpose. The section
explores the concept of constants and their implications for variable
scope.
// Constants with Global Scope in Java
public class ConstantsExample {
public static final double PI = 3.14; // Constant with global scope
// ...
}
Through examples like these, readers understand how constants can
achieve a form of global scope, providing consistent values across an
entire Java program.
Variable Lifetime: From Birth to Garbage Collection
The section transitions to the concept of variable lifetime, elucidating
when variables come into existence and when they are eventually
removed from memory. Local variables have a limited lifespan,
existing only within the scope of the method or block where they are
declared.
// Variable Lifetime in Java
public class LifetimeExample {
public void myMethod() {
int localVar = 42; // Local variable with limited lifetime
// ...
}
}
By exploring these examples, readers comprehend how variable
lifetime is intimately tied to their scope, influencing memory
management in Java programs.
Conclusion: Balancing Accessibility and Resource Management
The "Variable Scope and Lifetime in Java" section concludes by
emphasizing the delicate balance between variable accessibility and
resource management. By mastering the nuances of variable scope
and lifetime, readers gain the expertise to optimize their Java
programs for efficiency and reliability, ensuring that variables are
utilized precisely where needed and released when their purpose is
served. This foundational knowledge paves the way for constructing
robust and scalable Java applications within the broader context of
"Programming With Java."
Module 3:
Basic Input and Output in Java
In the expansive domain of Java programming, the module "Basic Input and
Output in Java" within the book "Programming With Java" stands as a
foundational exploration. This module serves as a vital entry point, guiding
learners through the essential facets of handling input and output in Java
applications. Mastering these fundamental skills is paramount for creating
programs that are not only dynamic and interactive but also capable of
processing data from external sources and generating meaningful output. As
we embark on this journey, we will unravel the intricacies of input and
output mechanisms, equipping readers with the tools necessary for user
interaction and practical software development.
Foundations of Input Handling in Java
Our exploration begins by unveiling the foundations of input handling in
Java. We will delve into the methods through which programs can receive
data, whether from users or external sources. The use of tools like the
Scanner class will be demystified, showcasing its versatility in capturing
user input. These discussions will form the groundwork for constructing
applications that actively engage with users, responding dynamically to
their input.
Effective Output Presentation in Java
Transitioning seamlessly, the module explores the art of output in Java,
emphasizing strategies for presenting information effectively. Techniques
such as System.out.println will be highlighted, enabling learners to convey
results, messages, or relevant information to the console or other output
streams. Through practical examples, readers will grasp the syntax and
applications of these output methods, understanding the power of clear and
concise communication in the context of software development.
File Input and Output Mastery
Expanding the scope, our journey extends into the realm of file input and
output – a pivotal skill for applications dealing with persistent data storage.
Classes like FileReader, BufferedReader, FileWriter, and PrintWriter
will be introduced, empowering readers with the ability to read from and
write to files. This newfound proficiency opens doors to handling external
data sources and enhancing the robustness of Java applications.
Conclusion: Empowering Interactive and Dynamic Java Programs
As the "Basic Input and Output in Java" module concludes, learners will
possess a transformative set of skills. The ability to handle input effectively,
present output dynamically, and manage external data sources empowers
developers to create interactive, dynamic, and user-friendly Java
applications. This foundational knowledge not only serves as a launching
pad for further exploration within "Programming With Java" but also
propels learners toward mastery in the realm of software development.
Using System.out.println and System.out.print for Output
The section on using System.out.println and System.out.print for
output is foundational within the module "Basic Input and Output in
Java" in the book "Programming With Java." This segment serves as
an initiation into the world of displaying information to the console, a
crucial skill for any Java programmer. The two primary methods,
System.out.println and System.out.print, are instrumental in
conveying output to the console window.
The System.out.println method is employed to print text or variables
to the console, followed by a newline character. This ensures that
subsequent output appears on a new line, enhancing readability.
Below is a simple example illustrating the use of System.out.println:
public class PrintExample {
public static void main(String[] args) {
System.out.println("Hello, World!");
int number = 42;
System.out.println("The value of the variable is: " + number);
}
}
In this example, the text "Hello, World!" is printed to the console
followed by the value of the variable number. The use of
System.out.println ensures that each statement is displayed on a new
line.
On the other hand, the System.out.print method achieves a similar
outcome but without appending a newline character. This means that
consecutive System.out.print statements will appear on the same line.
The following code snippet illustrates the use of System.out.print:
public class PrintExample {
public static void main(String[] args) {
System.out.print("Hello, ");
System.out.print("World!");
int number = 42;
System.out.print(" The value of the variable is: " + number);
}
}
In this example, the output will be "Hello, World! The value of the
variable is: 42" all on the same line due to the use of
System.out.print.
Understanding when to use System.out.println for new lines and
System.out.print for continuous output is crucial for crafting well-
formatted and readable console outputs in Java. This section serves as
a fundamental building block, setting the stage for learners to
progress to more complex input and output operations as they delve
deeper into the "Basic Input and Output in Java" module.
Reading User Input with Scanner Class
The section on reading user input with the Scanner class is a pivotal
component of the module "Basic Input and Output in Java" in the
book "Programming With Java." This segment introduces learners to
the essential skill of obtaining input from the user, enabling
interactive and dynamic Java programs. The Scanner class, part of the
java.util package, facilitates the reading of various types of input
from the console, providing a versatile tool for user interaction.
import java.util.Scanner;
public class UserInputExample {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter your name: ");
String name = scanner.nextLine();
System.out.println("Hello, " + name + "!");
System.out.print("Enter your age: ");
int age = scanner.nextInt();
System.out.println("You are " + age + " years old.");
scanner.close();
}
}
In this example, a Scanner object is created, initialized with
System.in to read input from the console. The program prompts the
user to enter their name and age, utilizes scanner.nextLine() to
capture a full line of text for the name, and scanner.nextInt() to
capture an integer for the age. The acquired input is then used to
generate personalized output messages.
The Scanner class provides various methods for reading different
data types, including nextLine() for strings, nextInt() for integers,
nextDouble() for doubles, and more. It allows developers to
interactively gather user input, enhancing the adaptability and user-
friendliness of Java applications.
Understanding the use of Scanner for user input is foundational for
creating applications that respond dynamically to user responses.
However, it's important to note that improper usage, such as not
closing the Scanner when done, can lead to resource leaks. Therefore,
as illustrated in the example, it's good practice to close the Scanner
using the close() method to release system resources associated with
it.
This section equips learners with the skills to make Java programs
interactive, fostering user engagement and expanding the scope of
applications. As learners progress through the "Basic Input and
Output in Java" module, they build a strong foundation for creating
versatile and user-centric Java programs within the broader context of
"Programming With Java."
Formatting Output with printf
The section on formatting output with printf is a crucial aspect of the
module "Basic Input and Output in Java" within the book
"Programming With Java." This segment introduces learners to the
powerful and flexible printf method, offering a sophisticated way to
control the appearance of output in the console. Derived from the C
programming language, printf allows for precise formatting, making
it an essential tool for crafting well-structured and visually appealing
output.
public class PrintfExample {
public static void main(String[] args) {
String name = "John";
int age = 25;
double salary = 50000.75;
System.out.printf("Name: %s%n", name);
System.out.printf("Age: %d%n", age);
System.out.printf("Salary: $%.2f%n", salary);
}
}
In this example, the printf method is utilized to format and print
information. The format specifier %s is used for strings, %d for
integers, and %f for floating-point numbers. The %n is a platform-
independent newline character, ensuring proper line breaks in
different operating systems. Additionally, .2 in %.2f specifies that the
floating-point number should be displayed with two decimal places.
Understanding the syntax and functionality of printf is fundamental
for developers striving to create output that is both readable and
visually consistent. The format specifiers within the format string act
as placeholders, and the corresponding values are supplied after the
string, ensuring a seamless connection between the format and the
actual data.
Developers can leverage a variety of format specifiers and modifiers
with printf, such as controlling the width and precision of numeric
values, specifying field alignment, and incorporating special
characters. This versatility empowers developers to tailor the output
according to specific requirements and enhances the overall aesthetic
of the displayed information.
The printf method not only offers enhanced formatting capabilities
but also contributes to code maintainability by keeping the formatting
details separate from the content. This separation allows developers
to modify the appearance of output without altering the underlying
logic, promoting clean and modular code.
As learners progress through the "Basic Input and Output in Java"
module, mastering the printf method provides a valuable skill set for
creating professional-looking and well-organized console output in
Java applications. It serves as a cornerstone for effective
communication of information to users and ensures that the visual
representation of data aligns with the overall quality of the code
within the broader context of "Programming With Java."
Debugging Techniques in Java
The section on debugging techniques in Java is an indispensable
component of the module "Basic Input and Output in Java" within the
book "Programming With Java." Debugging is a critical skill for any
developer, and this section introduces learners to various tools and
methodologies to identify, isolate, and rectify errors within their Java
code. Debugging is an iterative and problem-solving process, and
mastering these techniques is essential for writing robust and error-
free programs.
public class DebuggingExample {
public static void main(String[] args) {
int[] numbers = {1, 2, 3, 4, 5};
int sum = 0;
for (int i = 0; i <= numbers.length; i++) {
sum += numbers[i];
}
System.out.println("The sum is: " + sum);
}
}
In this example, a common mistake is made by using <= instead of <
in the loop condition. This error leads to an
ArrayIndexOutOfBoundsException as the loop attempts to access an
index beyond the array's bounds. Understanding how to identify and
rectify such errors is a key aspect of effective debugging.
Utilizing Breakpoints and Stepping Through Code
Debugging often involves stepping through the code to understand its
flow and identify where issues arise. Modern Integrated Development
Environments (IDEs) provide tools for setting breakpoints, allowing
developers to pause the program's execution at specific points and
inspect variable values. By stepping through the code, learners can
observe the state of variables and pinpoint the exact location of
errors.
public class DebuggingExample {
public static void main(String[] args) {
int[] numbers = {1, 2, 3, 4, 5};
int sum = 0;
for (int i = 0; i < numbers.length; i++) {
sum += numbers[i]; // Set a breakpoint here
}
System.out.println("The sum is: " + sum);
}
}
Setting a breakpoint on the line with the sum calculation allows
developers to observe the changing values of variables during each
iteration of the loop.
Leveraging Print Statements for Tracing Execution
Another fundamental debugging technique involves strategically
placing print statements in the code to trace its execution. This
method is especially useful for identifying the flow of control and
understanding how variables change at different points in the
program.
public class DebuggingExample {
public static void main(String[] args) {
int[] numbers = {1, 2, 3, 4, 5};
int sum = 0;
for (int i = 0; i < numbers.length; i++) {
System.out.println("Adding " + numbers[i] + " to the sum.");
sum += numbers[i];
}
System.out.println("The sum is: " + sum);
}
}
Print statements provide insight into the program's behavior, helping
learners identify unexpected values or iterations that lead to errors.
Exception Handling for Predictable Error Resolution
Understanding and implementing exception handling is a crucial
debugging technique. By catching and handling exceptions
gracefully, developers can prevent runtime crashes and create more
robust applications. This involves using constructs like try-catch
blocks to manage potential errors.
public class DebuggingExample {
public static void main(String[] args) {
int[] numbers = {1, 2, 3, 4, 5};
int sum = 0;
try {
for (int i = 0; i <= numbers.length; i++) {
sum += numbers[i];
}
} catch (ArrayIndexOutOfBoundsException e) {
System.err.println("Array index out of bounds. Ensure proper loop condition.");
}
System.out.println("The sum is: " + sum);
}
}
In this example, the try-catch block prevents the program from
crashing due to the ArrayIndexOutOfBoundsException by handling it
and providing a meaningful error message.
Understanding and applying these debugging techniques equips
learners with the tools necessary to identify and resolve issues within
their Java programs. This skill is invaluable for developers striving to
create reliable and efficient software within the broader context of
"Programming With Java."
Module 4:
Operators and Expressions in Java
Within the rich tapestry of Java programming, the module "Operators and
Expressions in Java" stands as a pivotal exploration within the pages of the
book "Programming With Java." This module serves as a fundamental
guide, unraveling the intricate world of operators and expressions in the
Java language. Operators are the building blocks of computation, and
expressions define the language's capability to articulate logic and
calculations. By delving into this module, readers embark on a journey to
comprehend the nuances of how Java handles operations, manipulates data,
and evaluates expressions – skills that are essential for constructing efficient
and meaningful Java programs.
Understanding Java Operators
The journey begins with a comprehensive exploration of Java operators –
symbols that represent computations, comparisons, and other operations.
From arithmetic operators like addition and subtraction to logical operators
such as AND and OR, the module dissects each category, elucidating their
roles and applications within the Java language.
Arithmetic Operators: Foundations of Calculation
Arithmetic operators form the bedrock of numerical computations in Java.
This section of the module delves into operators like +, -, *, /, and %,
unraveling their functionality and showcasing how they manipulate numeric
data. Through practical examples, learners gain insights into the precision
and rules governing arithmetic operations in Java.
Relational and Logical Operators: Crafting Conditions
The module seamlessly transitions into relational and logical operators,
exploring their significance in crafting conditional expressions. By
dissecting operators like ==, !=, &&, and ||, readers gain proficiency in
constructing logical conditions that dictate the flow of program execution.
Practical scenarios illustrate the use of these operators in decision-making
structures.
Bitwise and Assignment Operators: Precision and Manipulation
The exploration extends to bitwise and assignment operators, revealing
their role in precision manipulation and variable assignment. This section
guides learners through operators like &, |, ^, <<, >>, and =, showcasing
how they operate at the bit level and facilitate efficient data manipulation.
Understanding Java Expressions
As the module progresses, attention shifts to expressions – combinations of
operators and operands that produce a value. The intricacies of building
meaningful expressions are unveiled, emphasizing how Java evaluates
expressions and maintains data types during these evaluations.
Compound and Conditional Expressions: Building Complexity
This section of the module delves into compound and conditional
expressions, where multiple operators collaborate to yield more complex
results. By exploring expressions like a + b * c and x > 0 ? "Positive" :
"Negative", learners gain proficiency in constructing intricate expressions
that encapsulate varied logic within a single line of code.
Conclusion: Empowering Code with Operators and Expressions
As the "Operators and Expressions in Java" module concludes, readers
emerge equipped with a profound understanding of the tools that form the
backbone of Java computation. The ability to wield operators with precision
and construct expressive expressions empowers developers to articulate
intricate logic and build robust, efficient Java programs. This foundational
knowledge not only sets the stage for more advanced topics within
"Programming With Java" but also positions learners to tackle complex
programming challenges with confidence and finesse.
Arithmetic, Relational, and Logical Operators
The section on arithmetic, relational, and logical operators is a
fundamental exploration within the module "Operators and
Expressions in Java" in the book "Programming With Java." These
operators play a pivotal role in shaping the logic and functionality of
Java programs, providing the means to perform calculations, make
comparisons, and implement logical decisions.
public class OperatorsExample {
public static void main(String[] args) {
// Arithmetic Operators
int a = 10, b = 5;
int sum = a + b;
int difference = a - b;
int product = a * b;
int quotient = a / b;
int remainder = a % b;
// Relational Operators
boolean isEqual = a == b;
boolean isNotEqual = a != b;
boolean isGreater = a > b;
boolean isLessOrEqual = a <= b;
// Logical Operators
boolean logicalAnd = (a > 0) && (b > 0);
boolean logicalOr = (a > 0) || (b > 0);
boolean logicalNot = !(a > 0);
// Displaying Results
System.out.println("Arithmetic Operations:");
System.out.println("Sum: " + sum);
System.out.println("Difference: " + difference);
System.out.println("Product: " + product);
System.out.println("Quotient: " + quotient);
System.out.println("Remainder: " + remainder);
System.out.println("nRelational Operations:");
System.out.println("Is Equal: " + isEqual);
System.out.println("Is Not Equal: " + isNotEqual);
System.out.println("Is Greater: " + isGreater);
System.out.println("Is Less or Equal: " + isLessOrEqual);
System.out.println("nLogical Operations:");
System.out.println("Logical AND: " + logicalAnd);
System.out.println("Logical OR: " + logicalOr);
System.out.println("Logical NOT: " + logicalNot);
}
}
This example demonstrates the application of arithmetic operators (+,
-, *, /, %), relational operators (==, !=, >, <=), and logical operators
(&&, ||, !). These operators are fundamental for performing
mathematical calculations, making decisions based on conditions,
and creating logical flows within a program.
Arithmetic Operators for Numeric Calculations
Arithmetic operators are the building blocks for numeric calculations.
The addition (+), subtraction (-), multiplication (*), division (/), and
modulus (%) operators enable developers to perform various
mathematical operations. These operators are crucial for tasks such as
calculating totals, differences, products, and handling remainders.
Relational Operators for Comparisons
Relational operators facilitate comparisons between values. They
include equality (==), inequality (!=), greater than (>), and less than
or equal to (<=). These operators are vital for implementing decision-
making processes based on the relationships between variables.
Logical Operators for Decision Making
Logical operators are essential for crafting conditional statements.
The logical AND (&&), logical OR (||), and logical NOT (!)
operators enable developers to create complex decision structures by
combining and negating conditions. This flexibility is crucial for
controlling program flow based on multiple criteria.
Understanding and proficiently applying these operators is
foundational for writing expressive and functional Java code.
Whether performing numeric computations, making decisions based
on conditions, or creating complex logical structures, these operators
empower developers to craft efficient and logically sound programs.
As learners progress through the "Operators and Expressions in Java"
module, mastering these operators lays the groundwork for more
sophisticated programming constructs within the broader context of
"Programming With Java."
Operator Precedence and Associativity
The section on operator precedence and associativity is a critical
exploration within the module "Operators and Expressions in Java" in
the book "Programming With Java." These concepts define the order
in which operators are evaluated within expressions, ensuring the
correct interpretation of complex statements. Understanding operator
precedence and associativity is fundamental for writing precise and
unambiguous Java code.
public class OperatorPrecedenceExample {
public static void main(String[] args) {
int a = 5, b = 3, c = 2;
int result = a + b * c;
int anotherResult = (a + b) * c;
System.out.println("Result: " + result);
System.out.println("Another Result: " + anotherResult);
}
}
In this example, the expressions a + b * c and (a + b) * c illustrate the
significance of operator precedence. The multiplication operator (*)
takes precedence over the addition operator (+). Therefore, in the first
expression, b * c is evaluated first, followed by the addition of a. In
the second expression, the parentheses force the addition of a and b to
be evaluated before the multiplication by c.
Operator Precedence: Controlling the Order of Evaluation
Operator precedence establishes the hierarchy of operations in an
expression. It ensures that certain operations take precedence over
others during evaluation. For example, multiplication and division
typically have higher precedence than addition and subtraction.
Developers need to be aware of this hierarchy to write expressions
that produce the expected results.
public class OperatorPrecedenceExample {
public static void main(String[] args) {
int x = 10, y = 5, z = 2;
int result = x + y * z / 2;
System.out.println("Result: " + result);
}
}
In this example, the expression x + y * z / 2 is evaluated based on
operator precedence. The multiplication and division operations are
performed before the addition.
Operator Associativity: Resolving Equal Precedence
Operator associativity comes into play when operators of equal
precedence appear in an expression. It determines the order in which
operations are executed. For most operators in Java, associativity is
left-to-right. This means that operations with the same precedence are
executed from left to right.
public class OperatorAssociativityExample {
public static void main(String[] args) {
int p = 8, q = 4, r = 2;
int result = p / q / r;
System.out.println("Result: " + result);
}
}
In this example, the expression p / q / r is evaluated from left to right
due to left-to-right associativity. The division operations are
performed sequentially.
Understanding and correctly applying operator precedence and
associativity is crucial for writing expressions that yield the intended
results. Developers must consider these principles when crafting
complex statements to ensure the accuracy of calculations and the
reliability of their Java code. As learners progress through the
"Operators and Expressions in Java" module, mastering these
concepts becomes integral to writing efficient and error-free code
within the broader context of "Programming With Java."
Using Operators for Expressions in Java
The section on using operators for expressions in Java is a central
topic within the module "Operators and Expressions in Java" in the
book "Programming With Java." Operators are the building blocks of
expressions, enabling developers to create dynamic and sophisticated
computations. This section delves into the practical application of
operators to construct meaningful expressions, emphasizing their role
in mathematical calculations, logical evaluations, and variable
manipulations.
public class ExpressionsExample {
public static void main(String[] args) {
int a = 5, b = 3, c = 2;
// Arithmetic Expressions
int sum = a + b;
int difference = a - b;
int product = a * b;
int quotient = a / b;
int remainder = a % b;
// Logical Expressions
boolean isGreaterThan = a > b;
boolean isEqualOrLess = a <= b;
// Compound Expressions
boolean complexCondition = (a > b) && (b < c);
// Displaying Results
System.out.println("Arithmetic Expressions:");
System.out.println("Sum: " + sum);
System.out.println("Difference: " + difference);
System.out.println("Product: " + product);
System.out.println("Quotient: " + quotient);
System.out.println("Remainder: " + remainder);
System.out.println("nLogical Expressions:");
System.out.println("Is Greater Than: " + isGreaterThan);
System.out.println("Is Equal or Less: " + isEqualOrLess);
System.out.println("nCompound Expressions:");
System.out.println("Complex Condition Result: " + complexCondition);
}
}
This example showcases the use of various operators in constructing
expressions. Arithmetic expressions, utilizing operators such as +, -,
*, /, and %, perform mathematical calculations. Logical expressions,
with operators like >, <=, evaluate conditions and return boolean
results. Compound expressions combine multiple conditions using
logical operators (&& in this case) to create more intricate decision
structures.
Arithmetic Expressions: Performing Calculations
Random documents with unrelated
content Scribd suggests to you:
whole and unchangeable, unswerving and unadaptable. Perfectly
unadaptable. It is of such an one that I dream.”
Imhof jumped up, and smoothed his coat. “Talk, talk!” he rattled, in
the disagreeable military tone that he assumed in his moments of
pseudo-virility. “Talk won’t improve things.” He passed his arm
through Weikhardt’s, and as they left the terrace, which had been
gradually filling with other guests, he recited, boldly, unashamed,
and in the same tone, the alcaic stanza of Hölderlin:
“Still man will take up arms against all who breathe;
Compelled by pride and dread he consumes himself in conflict, and
destroys the lovely
Flower of his peace that is brief of blooming.”
VII
On their first evening in Hamburg, Crammon rented a box in the
playhouse, and invited Christian, Johanna Schöntag, and Herr
Livholm, one of the directors of the Lloyd, to be his guests. He had
made the latter’s acquaintance in the hotel where he had gone to
pay Eva a visit of welcome. He had liked the man, who cut a good
figure, and so he had added him to the party in order, as he put it,
to keep the atmosphere normal by the presence of an entirely
neutral person.
“Social skill,” he was accustomed to say, “is not unlike skill in cookery
and serving. Between two heavy, rich dishes there must be one like
foam that stimulates the palate quite superficially. Otherwise the
meal has no style.”
The play was a mediocre comedy, and Christian was frankly bored.
Crammon thought it his duty to show a condescending and muffled
amusement, and now and then he gave Christian a gentle poke, to
persuade him also to show some appreciation of the performance.
Johanna was the only one who was genuinely amused. The source
of her amusement was an actor to whom a serious rôle had been
assigned, but who talked with such silly affectation and false
importance that every time he appeared she had to hold her lacy
handkerchief to her lips to smother her laughter.
Occasionally Christian gave the girl a far and estranged glance. She
wasn’t either agreeable or the reverse; he did not know what to
make of her. This feeling of his had not changed since he had first
seen her during the journey in Eva’s company.
She felt the coldness of his glance. Her merriment did not vanish;
but on the lower part of her face appeared a scarcely perceptible
shadow of disappointment.
As though seeking for help, she turned to Christian. “The man is
terribly funny, don’t you think so?” It was characteristic of her to end
a question with a negative interrogation.
“He’s certainly worth seeing,” Christian agreed politely.
The door of the box opened, and Voss entered. He was faultlessly
dressed for the occasion; but no one had expected or invited him.
They looked at him in astonishment. He bowed calmly and without
embarrassment, stood quite still, and gave his attention to the stage.
Crammon looked at Christian. The latter shrugged his shoulders.
After a while Crammon arose, and with sarcastic courtesy pointed to
his seat. Voss shook his head in friendly refusal, but immediately
thereafter assumed once more his air of humility and abjectness. He
stammered: “I was in the stalls and looked up. I thought there was
no harm in paying a visit.” Suddenly Crammon went out, and was
heard quarrelling with the usher. Johanna had become serious, and
looked down at the audience. Christian, as though to ward off
disagreeable things, ducked his shoulders a little. The people in the
near-by seats became indignant at the noise Crammon was making.
Herr Livholm felt that the proper atmosphere had hardly been
preserved. Amadeus Voss alone showed himself insensitive to the
situation.
He stood behind Johanna, and thought: “The hair of this woman has
a fragrance that turns one dizzy.” At the end of the act he withdrew,
and did not return.
Late at night, when he had him alone, Crammon vented his rage on
Christian. “I’ll shoot him down like a mad dog, if he tries that sort of
thing again! What does the fellow think? I’m not accustomed to such
manners. Damned gallow’s bird—where’d he grow up? Oh, my
prophetic soul! I always distrusted people with spectacles. Why don’t
you tell him to go to hell? In the course of my sinful life, I’ve come in
contact with all kinds of people; I know the best and I know the
dregs; but this fellow is a new type. Quite new, by God! I’ll have to
take a bromide, or I won’t be able to sleep.”
“I believe you are unjust, Bernard,” answered Christian, with lowered
eyes. But his face was stern, reserved, and cold.
VIII
Amadeus Voss submitted the following plan to Christian: to go to
Berlin, first as an unmatriculated student, and later to prepare
himself for the state examination in medicine.
Christian nodded approvingly, and added that he intended to go to
Berlin shortly too. Voss walked up and down in the room. Then he
asked brusquely: “What am I to live on? Am I to address envelopes?
Or apply for stipends? If you intend to withdraw your friendship and
assistance, say so frankly. I’ve learned to wade through the mud.
The new kind won’t offer more resistance than the old.”
Christian was thoroughly surprised. A week ago, in Holland, he had
given Amadeus ten thousand francs. “How much will you need?” he
asked.
“Board, lodging, clothes, books....” Voss went over the items, and his
expression was that of one who formulates demands and uses the
tone of request only as a matter of courtesy. “I’ll be frugal.”
“I shall order two thousand marks a month to be sent you,” Christian
said, with an air of aversion. The impudent demand for money
pained him. Possession weighed upon him like a mountain. He could
not get his arms free nor lift his chest, and the weight grew heavier
and heavier.
In a bowl of chrysolite on the table lay a scarf-pin with one large,
black pearl. Voss, whose hands always groped for some occupation,
had taken it up, and held it between his thumb and index finger
against the light. “Do you want the pin?” Christian asked. “Take it,”
he persuaded Amadeus, who was hesitating. “I really don’t care
about it.”
Voss approached the mirror, and with a curious smile stuck the pin
into his cravat.
When Christian was left alone, he stood for a while quite lost in
thought. Then he sat down, and wrote to his manager at Christian’s
Rest. He wrote in his lanky script and his no less awkward style. “My
dear Herr Borkowski:—I have determined to sell Christian’s Rest,
together with all furnishings and objects of art, as well as the park,
woods, and farms. I herewith commission you to find a capable and
honest real estate dealer, who might telegraph me any favourable
offers. You know people of that sort, and need merely drive over to
Frankfort. Have the kindness to settle the matter as quietly as
possible. No advertisements are to appear in the press.”
Then he wrote a second letter to the manager of his racing stable at
Waldleiningen. To write this he had to do more violence to his heart
than the first had cost him, for he saw constantly fixed upon him the
gentle or spirited eyes of the noble animals. He wrote: “My dear
Herr Schaller:—I have determined to discontinue my racing stable.
The horses are to be sold at auction or quietly to fanciers. I should
prefer the latter method, and I suppose you share that feeling.
Baron Deidinger of Deidingshausen was at one time much interested
in Columbus and the mare Lovely. Inquire of him whether he wants
them. Admirable and Bride o’ the Wind could be offered either to
Prince Pless or Herr von Strathmann. Have my friend Denis Lay’s
Excelsior sent to Baden-Baden, and boarded temporarily in the
stables of Count Treuberg. I don’t wish him to remain at
Waldleiningen alone.”
When he had sealed the letters, he sighed with relief. He rang, and
gave the letters to his valet. The latter had turned to go, when
Christian called him back. “I’m very sorry to have to give you notice,
Wilhelm,” he said. “I’m going to attend to myself hereafter.”
The man could not trust his ears. He had been with Christian for
three years, and was genuinely devoted to him.
“I’m sorry, but it’s necessary,” said Christian, looked past the man,
and had almost the same strange smile with which he had watched
Amadeus Voss at the mirror putting the black pearl pin into his
cravat.
IX
Crammon asserted that Amadeus Voss was paying his attentions to
Johanna Schöntag. Johanna was annoyed, and tapped him with her
long gloves. “I congratulate you on your conquest, Rumpelstilzkin,”
Crammon teased her. “To have a monster like that in leash is no
small achievement. I should advise muzzling the monster, however.
What do you think, Christian, wouldn’t you advise a muzzle, too?”
“A muzzle?” answered Christian. “Yes, if it would keep people from
talking. So many talk too much.”
Crammon bit his lips. The reproof struck him as harsh. Somewhere
beneath the downs of life on which he lay and enjoyed himself, there
was, evidently, a stone. The stone hurt. He sought for it, but the
softness of the down calmed him again, and he forgot his pain.
“I was sitting in the breakfast room, and waiting for Madame Sorel,”
Johanna began in a voice whose every shading and inflection sought
to woo Christian’s ear, “when Herr Voss came in and marched
straight up to me. ‘What does that bad man want of me?’ I asked
myself. He asked me, as though we’d been bosom friends for years,
whether I didn’t want to go with him to St. Paul’s to hear the famous
itinerant preacher Jacobsen. I couldn’t help laughing, and he stalked
away insulted. But this afternoon, as I was leaving the hotel, he
seemed suddenly to spring from the earth, and invited me to a trip
around the harbour. He had rented a motor launch, and was looking
for a companion. He had the same gruff familiarity, and when he left
he was quite as insulted as before. And you call that paying
attentions? I felt much more as though he were going to drag me off
and murder me. But perhaps that’s only his manner.” She laughed.
“You’re the only person, at all events, whom he distinguishes by
observing at all,” Crammon said, with the same mockery.
“Or the only one whom he considers his equal,” Johanna said, with a
childlike frown.
Christian was wondering: “Why does she laugh so often? Why are
her hands so pudgy and so very pink?” Johanna felt his disapproval,
and was as though paralysed. And yet Christian felt himself drawn
toward her by some hidden power.
Why should he resist? Why be so ceremonious? Such was his
thought, as Johanna arose, and he, with unobtrusive glances,
observed her graceful form that still possessed the flexibility of
immaturity. He saw the nape of her slender neck, in which were
expressed both the weakness of her will and the fineness of her
temper. He knew these signs; he had often been guided by them
and used them.
Crammon, massive and magnificent in a great easy chair, spoke with
some emphasis of Eva’s appearance on the morrow. The whole city
was in a state of expectancy. But Christian and Johanna had
suddenly become truly aware of one another.
“Are you coming along?” Christian turned carelessly, and with a
sense of boredom, to Crammon.
“Yes, my boy, let us eat!” Crammon cried. He called Hamburg the
Paradise of Saint Bernard, concerning whom, as his patron saint and
namesake, he had instituted especial investigations, and who,
according to him, had been a mighty trencherman during his lifetime
at Tours.
A frightened, subtle, and very feminine smile hovered about
Johanna’s lips. As she preceded the two men, the motions of her
dainty body expressed a vague oppression of the spirit, and at the
same time a humorous rebellion against her own unfreedom.
X
Amadeus Voss knew that he had no one’s sympathy, no one’s except
Christian’s. And him he suspected, watching him, weighing and
analysing his words and actions. In his terror of hypocrisy and
treachery, he practised both himself. Nothing healed or convinced or
reconciled him. Least of all did he pardon Christian the fact that the
latter’s glance and presence had the effect of subduing him. His
bitterness moaned from his very dreams.
He read in the Scriptures: “There was a certain house-holder, which
planted a vineyard, and hedged it round about, and digged a
winepress in it, and built a tower, and let it out to husbandmen, and
went into a far country: and when the time of the fruit drew near, he
sent his servants to the husbandmen that they might receive the
fruits of it. And the husbandmen took his servants, and beat one,
and killed another, and stoned another. Again he sent other servants,
more than the first, and they did unto them likewise. But last of all,
he sent unto them his son, saying, They will reverence my son. But
when the husbandmen saw the son, they said among themselves,
This is the heir; come, let us kill him, and let us seize on his
inheritance. And they caught him, and cast him out of the vineyard,
and slew him.”
Sometimes he would not leave Christian’s side for hours. He would
study his gestures and the expressions of his countenance, and all
these perceptions fed the corrosive fire in his brain. For this was the
heir! Then he would flee and bruise and stamp upon his very soul,
until his consciousness of guilt cast him down into the very dust. He
would return, and his demeanour would be a silent confession: “I
can thrive only in your presence.” It seemed to him that this silence
of his was like a cry; but it was not heard, and so his brother
seemed again to become his foe. Thus he kept passing from
darkness, through fires and fumes, back into the darkness.
He suffered from his own embarrassment and importunateness. In
the midst of luxury and plenty, into which he had been transferred
by a fabulous turn of fortune, he suffered from the memories of his
former poverty, still felt how it had bound and throttled him, and still
rebelled against what was gone. He could not freely take what was
given him, but closed his eyes, and shuddered with both desire and
a pang of conscience. He would not look upon the pattern of his web
of life. He turned its texture around, and brooded over the
significance of the intricately knotted threads. And there was no
human relationship which did not rouse his suspicion, no harmless
conversation in which he did not seek a sting directed toward
himself, no face that did not feed his hatred, no beauty whose
counter part of ugliness he did not see. To him everything turned to
poison and decay, all blossoms became noxious weeds, all velvet a
Nessus shirt, all light an evil smouldering, every stimulus a wound:
on every wall he saw the flaming letters, mene tekel upharsim.
He could not yield himself or conquer the stubbornness of his heart.
With the object of his desire in his very hands, his envy burned on.
Whatever had once humiliated him spurred his vengefulness through
retrospection. Chastisements which his father had inflicted distorted
the old man’s image beyond the grave; his fellow pupils in the
seminary had once strewn pepper into his coffee, and he could not
forget it; he could not forget the expression on the face of Adeline
Ribbeck with which she had given him his first month’s salary in a
closed envelope; he remembered the contempt and contumely of
hundreds, who had inflicted upon him their revenge for the
oppression or degradation which they themselves had endured. He
could not conquer these things nor forgive fate. The marks that had
been burned into his flesh throbbed like new wounds.
But at other times he would cast himself into the dust in prayer and
in great need of forgiveness. Religious scruples plagued him into
remorse; he panted for an hour’s release from consciousness,
judged himself with cruel severity, and condemned himself to ascetic
practices.
And these hurled him into the other extreme of a wild,
undiscriminating, and senseless dissipation and a mad waste of
money. He could no longer resist the excitement of gambling, and
fell into the hands of sharpers, drifted into loathsome dives, where
he acted the part of a wealthy man and an aristocrat in incognito,
for he desired to test this human mask and prove its worthlessness
to himself. Since his companions took him seriously in this rôle,
which filled his own mind with shame and despair, he took his high
losses with apparent calm, and overlooked the open cheating. One
evening the den in which he happened to be was raided by the
police, and he escaped by a hair’s breadth. One creature clung to
him, frightened him with possible dangers ahead, threatened
exposure, and wrung from him a considerable sum of hush money.
He became the prey of cocottes. He bought them jewels and frocks
and instituted nightly revels. In his eyes they were outcasts that he
used as a famishing man might slake his thirst at a mud puddle with
no clean water within reach. And he was brutally frank with them.
He paid them to endure his contempt. They were surprised, resisted
only his most infamous abuses, and laughed at his unconquerable
traits of the churchly hypocrite. Once he remained alone with a girl
who was young and pretty. He had blindfolded himself. But suddenly
he fled as though the furies were at his heels.
Thrice he had set the date for his departure and as many times had
put it off. The image of Johanna had joined that of Eva in his soul,
and both raged in his brain. Both belonged to an unattainable world.
Yet Johanna seemed less alien; she might conceivably hear his plea.
Eva and her beauty were like a strident jeer at all he was. He had
heard so much and read so much of her art that he determined to
await her appearance, in order (as he told Christian) to form a
judgment of his own, and be no longer at the mercy of those who
fed her on mere adulation and brazen flattery.
The audience was in full evening dress. Amadeus sat next to
Christian in the magnificent and radiant hall, in which had gathered
royal and princely persons, the senators of the free city, the heads of
the official and financial world, and representatives of every valley
and city of Germany. Christian had bought seats near the stage.
Crammon, who was an expert in matters of artistic perspective, had
preferred the first row in the balcony. With him were Johanna and
Botho von Thüngen, to whom he had emphatically explained that
the play of the dancer’s feet and legs was interfered with by the dark
line of the stage below, while from their present position its full
harmony would be visible.
Amadeus Voss had almost determined to remain rigid in mind. He
hardly resisted actively, for he did not expect anything powerful
enough to make resistance worth while. He was cold, dull, unseeing.
Suddenly there floated upon the stage a bird-like vision, a being
miraculously eased of human heaviness, one who was all rhythm,
and turned the rhythm of motion into music. She broke the chains of
the soul, and made every emotion an image, every action a myth,
every step a conquest over space and matter. But the face of
Amadeus seemed to say: How can that serve me? How does that
serve you? Filled by the fury of sex, he saw only a scabrous
exhibition, and when the thunder of applause burst out, he showed
his teeth.
Eva’s last number was a little dramatic episode, a charming jeu
d’esprit, which she had invented and worked out, to be accompanied
by a composition of Delibes. It was very simple. She was Pierrot
playing with a top. She regulated and guided the whimsical course of
the toy. In ever new positions, turns, and rhythms, she finally drove
the top toward a hole into which it disappeared. But this trivial
action was so filled with life by the wealth and variety of her
rhythmic gestures, so radiant with spirit and swiftest grace, so fresh
in inspiration, so heightened in the perfection of its art, that the
audience watched breathlessly, and released its own tensity in a fury
of applause.
In the foyer Crammon rushed up to Christian, and drew him through
the crowd along the dim passage way that led back of the stage.
Amadeus Voss, unnoticed by Crammon, followed them unthinkingly
and morosely. The sight of the wings, of cliffs and trees, of discarded
drops, electrical apparatus and pulleys and of the hurrying stage-
hands, stirred in him a dull and hostile curiosity.
An excited crowd thronged toward Eva’s dressing-room. She sat in
the silken Pierrot costume of black and white, the dainty silver whip
still in her hand, amid a forest of flowers. Before her kneeled
Johanna Schöntag with an adoring moisture in her eyes. Susan gave
her mistress a glass of cool champagne. Then in a mixture of five or
six languages she tried to make it clear to the unbidden guests that
they were in the way. But each wanted a look, a word, a smile of
Eva for himself.
Next to the room in which Eva sat, and separated from it by a thin
partition with an open door, was a second dressing-room, which
contained only her costumes and a tall mirror. Accidentally pushed in
that direction, and not through any will of his own, Amadeus Voss
suddenly found himself alone in this little chamber. Having entered
it, his courage grew, and he ventured a little farther in.
He looked around and stared at the garments that lay and hung
here—the shimmering silks, the red, green, blue, white, and yellow
shawls and veils, the fragrant webs of gauze, batiste, and tulle.
There were wholly transparent textures and the heaviest brocades.
One frock glowed like pure gold, another gleamed like silver; one
seemed made of rose-leaves, another knitted of spun glass, one of
white foam and one of amethyst. And there stood dainty shoes—a
long row of them, shoes of Morocco leather and of kid and silk; and
there were hose of all colours, and laces and ribands and antique
beads and brooches. The air was drenched with a fragrance that
stung his senses—a fragrance of precious creams and unguents, of a
woman’s skin and hair. His pulses throbbed and his face turned grey.
Involuntarily he stretched out his hand, and grasped a painted
Spanish shawl. Angrily, greedily, beside himself, he crushed it in his
hands, and buried his mouth and nose in it and trembled in every
limb.
At that moment Susan Rappard saw him, and pointed to him with a
gesture of astonishment. Eva saw him too, gently thrust Johanna
aside, arose, and approached the threshold. When she saw the man
in his strange and absorbed ecstasy, she felt as though she had been
spattered with filth, and uttered a soft, brief cry. Amadeus Voss
twitched and dropped the shawl. His eyes were wild and guilty. With
a light laugh and an expression of transcendent contempt, which
summed up a long dislike, Eva raised the little silver whip and struck
him full in the face. His features grew very white, in a contortion of
voluptuousness and terror.
In the tense silence Christian went up to Eva, took the silver whip
from her hand, and said in a tone scarcely distinguishable from his
habitual one: “Oh, no, Eva, I shall not let you do that.” He held the
handle of the whip firmly at both ends, and bent it until the fragile
metal snapped. Then he threw the two pieces on the floor.
They gazed at each other. Disgust at Amadeus still flamed in Eva’s
face. It yielded to her astonishment at Christian’s temerity. But
Christian thought: “How beautiful she is!” And he loved her. He loved
her in her black and white Pierrot’s costume with the black velvet
buttons, he loved her with that little cap and its impudent little tassel
on her head; he loved her, and she seemed incomparable to him,
and his blood cried out after her as in those nights from which she
had driven him forth. But he also asked himself: “Why has she
grown evil?” And a strange compassion for her stole over him, and a
stranger sense of liberation. And he smiled. But to all who were
watching, this smile of his seemed a little empty.
Again Amadeus Voss read in the Scripture: “What mean ye that ye
beat my people to pieces, and grind the faces of the poor? Because
the daughters of Zion are haughty, and walk with stretched forth
necks and wanton eyes, walking and mincing as they go, and
making a tinkling with their feet: Therefore the Lord will strike with a
scab the crown of the head of the daughters of Zion, and the Lord
will discover their secret parts. In that day will the Lord take away
the bravery of their tinkling ornaments about their feet, and their
cauls, and their round tires like the moon, the chains, and the
bracelets, and the mufflers, the bonnets, and the ornaments of the
legs, and the headbands, and the tablets, and the earrings, the
rings, and nose jewels, the changeable suits of apparel, and the
mantles, and the wimples, and the crisping pins, the glasses, and
the fine linen, and the hoods and the veils. And it shall come to
pass, that instead of sweet smell there shall be stink; and instead of
a girdle a rent; and instead of well set hair baldness; and instead of
a stomacher a girding of sack-cloth; and burning instead of beauty.
Thy men shall fall by the sword, and thy mighty in the war. And her
gates shall lament and mourn; and she being desolate shall sit upon
the ground.”
On the same evening he left for Berlin.
XI
Lorm and Judith had a magnificent apartment near the Tiergarten in
Berlin.
Edgar Lorm flourished. Order and regularity ruled his life. With
childlike boastfulness he spoke of his home. His manager and friend,
Dr. Emanuel Herbst, congratulated him on his visible rejuvenation.
He introduced to Judith the people whom he had long valued; but
she judged most of them sharply and without sympathy. Her
characteristic arrogance drove away many who meant well. But
under the sway of his new comforts Lorm submitted to her opinions.
But he would not give up Emanuel Herbst. When Judith mocked at
his waddling gait, his homeliness, his piping voice, his tactless jokes,
Lorm grew serious. “I’ve known him for over twenty years. The
things that annoy you endear him to me quite as much as those
precious qualities in him which I know well, and which you’ve had no
chance to discover.”
“No doubt he’s a monster of virtue,” Judith replied, “but he bores me
to extinction.”
Lorm said: “One should get used to the idea that other people don’t
exist exclusively for our pleasure. Your point of view is too narrowly
that of use and luxury. There are human qualities that I value more
highly than a handsome face or polished manners. One of these is
trustworthiness. People with whom one has professional dealings
often refuse to honour the demands of common decency—especially
in regard to the keeping of their given word—with a calm frivolity
that makes one’s gorge rise. So I’m intensely grateful to Herbst,
since it means so infinitely much to me, for this—that our relations
have never been shadowed by distrust, and that our simplest verbal
agreements are as firm and as valid as a written contract.”
Judith recognized that in this case she would have to change her
tactics. She was amiable, as though she were convinced of his
virtues, and sought to gain his favour. Dr. Herbst saw through her,
but showed no consciousness of his insight. He treated her with an
elaborate courtesy that seemed a trifle old-fashioned, and effectually
concealed his reservations.
Sometimes in the evening she would sit with the two men, and join
in their shop talk of playwrights and plays, actors and actresses,
successes and failures. And while she seemed attentive, and even
asked an occasional question, she thought of her dressmaker, of her
cook, of her weekly account, or of her old life, that was so different
and had perished so utterly. And her eyes would grow hard.
It would happen that she would pass through the rooms with a
bitter expression on her face and a hostile glance for the things
about her. She hated the many mirrors which Lorm required, the
rugs that had been recently bought, the pretentious furniture and
paintings, the countless bibelots, photographs, ornaments, books,
and piously guarded souvenirs.
She had never before lived in a house where other tenants above
and below reminded her of their repulsive and unfamiliar lives. She
listened to the slightest noises, and felt that she had fallen into a
slum.
It was hardly in harmony with her nature to wait each morning until
her husband happened to rise, to see that the breakfast was
complete, to stand aside while the barber, the masseur, the
chauffeur, the messenger of the theatre, and the secretary had
completed their tasks or received their instructions; to wait again
until he returned from rehearsal, tired, annoyed, and hungry, and
then to watch him at luncheon—a meal that he required to be both
rich and exquisite—gobble his food; to guard him from noise and
interruption when he memorized his lines; to answer strange voices
on the telephone, to give information, refuse invitations, to send the
troublesome away and to soothe the impatient. She was wholly out
of her natural element, but she forced herself to endure even as she
had endured bodily pain when the long needle had been thrust
through her arm.
Emanuel Herbst, who was a keen observer and a learned student of
human nature, quietly analysed the relations of this husband and
this wife. He said to himself: “Lorm is not fulfilling her expectations;
so much is clear. She fancied she could peel him the way one peels
an onion, and that the removal of each layer would reveal something
so new and surprising as to make up to her for all she has
renounced. She will soon discover her miscalculation, for Lorm is
always the same. He can’t be stripped. He wears his costumes and
puts on make-up. She will soon reproach him for this very ability to
fill empty forms with a beautiful content, and to remain, in his own
person, but a humble servitor of his art. And the more guilty he
becomes in her eyes, the more power over him will she gain. For he
is tired—tired to death of the affected, the flatterers and
sentimentalists, of the sweets and easements of his daily life.
Terribly spoiled as he is, he yearns unconsciously for chains and a
keeper.”
The result of his reflection filled Emanuel Herbst with anxious
apprehension.
But Judith remembered her dream—how she had lain beside a fish
because it pleased her, and then beaten it in sudden rage over its
cool, moist, slippery, opalescent scales. And she lay beside the fish
and struck it, and the fish became more and more subservient and
her own.
Her constant terror was this thought: “I am poor, impoverished,
dependent, without security.” The thought tormented her to such a
degree that she once expressed it to the housekeeper. The latter
was astonished and replied: “But in addition to your pin money, the
master gives you two thousand marks a month for the house. Why
should you yield to morbid fancies?”
Judith looked at the woman suspiciously. She distrusted all whom
she paid. The moment they mentioned money she fancied herself
robbed.
One day the cook gave notice. She was the fourth since the
establishment of the household. A quantity of sugar was missing.
There was a quarrel, an ugly one, and Judith was told things that no
one had ever dared to tell her before.
The secretary mislaid a key. When at last it was found Judith rushed
to the drawer which it fitted to see whether the stationery, the
pencils, and the pen-points were intact.
The housekeeper had bought twenty yards of linen. Judith thought
the price paid too high. She drove to the shop herself. The taxi-fare
amounted to more than she could possibly have saved on the
purchase. Then she chaffered with the clerk for a reduction, until it
was granted her through sheer weariness. She told Lorm the story
with a triumphant air. He neglected to praise her. She jumped up
from the table, locked herself in her room, and went to bed.
Whenever she thought that she had some reason for anger, she
went to bed.
Lorm came to her door, knocked softly, and asked her to open it.
She let him stand long enough to regret his conduct, and then
opened the door. She told her story all over, and he listened with a
charming curiosity on his face. “You’re a jewel,” he said, and stroked
her cheek and hand.
But it would also happen, if she really wanted something, that she
would spend sums out of all proportion to her wretched little
economies. She would see a hat, a frock, an ornament in a show
window, and not be able to tear herself away. Then she would go
into the shop, and pay the price asked at once.
One day she visited an auction sale, and happened to come in just
as an old Viennese bon-bon dish was offered for sale. It was one of
those objects that make little show, but which delight the collector’s
heart. At first the dish didn’t tempt her at all. Then the high bidding
for it excited her, and she herself began to bid for it. It kindled
something in her, and she made bid after bid, and drove all
competitors from the field.
Hot and excited, she came home and rushed into Lorm’s study.
Emanuel Herbst was with him. The two men sat by the fire in
familiar talk. Judith disregarded Herbst. She stood before her
husband, unwrapped the dish, and said: “Look at this exquisite thing
I bought, Edgar.”
It was toward evening, but no lights had been lit. Lorm loved the
twilight and the flicker of the fire in his chimney, which was, alas,
only a metropolitan imitation of a log fire. In the rich, red, wavering
reflection of the glow, Judith looked charming in her delight and
mobility.
Lorm took the dish, regarded it with polite interest, drew up his lips
a little, and said: “It’s pretty.” Herbst’s face puckered into
innumerable ironical little wrinkles.
Judith grew angry. “Pretty? Don’t you see that it’s magical, a perfect
little dream, the sweetest and rarest thing imaginable? The
connoisseurs were wild after it! Do you know what it cost? Eighteen
hundred marks. And I had six or seven rabid competitors bidding
against me. Pretty!” She gave a hard little laugh. “Give it to me. You
handle it too clumsily.”
“Calm yourself, sweetheart,” said Lorm gently. “I suppose its virtues
are subtle.”
But Judith was hurt, more by Herbst’s silent mockery than by Lorm’s
lack of appreciation. She threw back her head, rustled through the
room, and slammed the door behind her. When she was angry, her
own manners had, at times, a touch of commonness.
For a while the two men were silent. Then Lorm, embarrassed and
with a deprecating smile, said: “A little dream ... for eighteen
hundred marks.... Oh, well! There’s something childlike about her.”
Emanuel Herbst rubbed his tongue up and down between his teeth
and his upper lip. It made him look like an ancient baby. Then he
ventured: “You ought to make it clear to her that eighteen hundred
marks are one thousand eight hundred times one mark.”
“She won’t get that far,” answered Lorm. “Somebody who has always
lived on the open sea, and is suddenly transported to a little inland
lake, finds it hard to get the new measurements and perspectives.
But women are queer creatures.” He sighed and smiled. “Have a nip
of whiskey, old man?”
Sorrowfully Herbst rocked his Cæsarean head. “Why queer? They
are as they are, and one must treat them accordingly. Only one
mustn’t be under any mistaken impression as to what one has. For
instance: A horseshoe is not birch wood. It looks like a bow, but you
can’t bend it—not with all your might. If you string it, the string
droops slackly and will never propel your arrow. All right, let’s have
your whiskey.”
“But occasionally,” Lorm replied cheerfully, and filled the tiny glasses,
“you can turn a horseshoe into the finest Damascene steel.”
“Bravo! A good retort! You’re as ready as Cardinal Richelieu. Your
health!”
“If you’ll let me be Richelieu, I’ll appoint you to be my Father
Joseph. A great rôle, by the way. Your health, old man!”
XII
Crammon and Johanna Schöntag planned to drive to Stellingen to
see Hagenbeck’s famous zoological gardens, and Crammon begged
Christian to lend them his car. They were just about to start when
Christian issued from the hotel. “Why don’t you come along?”
Crammon asked. “Have you anything better to do? The three of us
can have a very amusing time.”
Christian was about to refuse, when he caught Johanna’s urgent and
beseeching look. She had the art of putting her wishes into her eyes
in such a way that one was drawn by them and lost the power to
resist. So he said: “Very well, I’ll come along,” and took the seat next
to Johanna’s. But he was silent on the whole drive.
It was a sunny day of October.
They wandered through the park, and Johanna made droll
comments on the animals. She stopped in front of a seal, and
exclaimed: “He looks quite like Herr Livholm, don’t you think so?”
She talked to a bear as though he were a simple sort of man, and
fed him bits of sugar. She said that the camels were incredible, and
only pretended to look that way to live up to the descriptions in the
books of natural history. “They’re almost as ugly as I am,” she
added; and then, with a crooked smile: “Only more useful. At least I
was told at school that their stomachs are reservoirs of water. Isn’t
the world a queer place?”
Christian wondered why she spoke so contemptuously of herself.
She bent over a stone balustrade, and the sight of her neck
somehow touched him. She seemed to him a vessel of poor and hurt
things.
Crammon discoursed. “It is very curious about animals. Scientists
declare they have a great deal of instinct. But what is instinct? I’ve
usually found them to be of an unlimited stupidity. On the estate
where I passed my childhood, we had a horse, a fat, timid, gentle
horse. It had but one vice: it was very ticklish. I and my playmates
were strictly enjoined from tickling it. Naturally we were constantly
tempted to tickle it. There were five of us little fellows—no higher
than table legs. Each procured a little felt hat with a cock’s feather in
it. And as the horse stood dull-eyed in front of the stable, we
marched in single file under the belly of the stupid beast, tickling it
with our feathers as we passed. The feathers tickled so frightfully
that he kicked with all fours like a mule. It’s a riddle to me to this
day how one of us, at least, failed to be killed. But it was amusing
and grotesque, and there was no sign of instinct anywhere.”
They went to the monkey house. A crowd stood about a little
platform, on which a dainty little monkey was showing off its tricks
under the guidance of a trainer. “I have a horror of monkeys,” said
Crammon. “They annoy me through memory. Science bids me feel a
relationship with them; but after all one has one’s pride. No, I don’t
acknowledge this devilish atavism.” He turned around, and left the
building in order to wait outside.
Alone with Christian, a wave of courage conquered Johanna’s
timidity. She took Christian’s arm and drew him nearer to the
platform. She was utterly charmed, and her delight was childlike.
“How dear, how sweet, how humble!” she cried. A spiritual warmth
came from her to Christian. He yielded himself to it, for he needed
it. Her boyish voice, however, stirred his senses and aroused his fear.
She stood very close by him; he felt her quiver, the response to the
hidden erotic power that was in him, and the other voices of his soul
were silenced.
He took her hand into his. She did not struggle, but a painful tension
showed in her face.
Suddenly the little monkey stopped in its droll performance and
turned its lightless little eyes in terror toward the spectators. Some
shy perception had frightened it; it seemed, somehow, to think and
to recollect itself. As it became aware of the many faces, the
indistinctness of its vision seemed to take on outline and form.
Perhaps for a second it had a sight of the world and of men, and
that sight was to it a source of boundless horror. It trembled as in a
fever; it uttered a piercing cry of lamentation; it fled, and when the
trainer tried to grasp it, it leaped from the platform and frantically
sought a hiding-place. Tears glittered in its eyes and its teeth
chattered, and in spite of the animal characteristics of these gestures
and expressions, there was in them something so human and soulful
that only a few very coarse people ventured to laugh.
To Christian there came from the little beast a breath from an alien
region of earth and forests and loneliness. His heart seemed to
expand and then to contract. “Let us go,” he said, and his own voice
sounded unpleasantly in his ears.
Johanna listened to his words. She was all willingness to listen, all
tension and all sweet humility.
XIII
Randolph von Stettner had arrived. There were still several days
before the date of his sailing, and he was on his way to Lübeck,
where he wished to say good-bye to a married sister. Christian
hesitated to promise to be in Hamburg on his friend’s return. Only
after much urging did he consent to stay.
They dined in Christian’s room, discussed conditions in their native
province, and exchanged reminiscences. Christian, laconic as usual,
was silently amazed at the distance of all these things from his
present self.
When the waiter had removed the dishes, Stettner gave an account
of all that had driven him to the determination to expatriate himself.
While he talked he stared with an unchanging look and expression at
the table cover.
“You know that for some years I’ve not been comfortable in my
uniform. I saw no aim ahead except the slow and distant moments
of advancement. Some of my comrades hoped for war. Well, the life
makes that hope natural. In war one can prove one’s self in the only
way that has any meaning to a professional soldier in any army. But
personally I couldn’t share that hope. Others marry money, still
others go in for sports and gambling. None of these things attracted
me. The service itself left me utterly dissatisfied. I seemed to myself
in reality an idler who lives pretentiously on others.
“Imagine this: you stand in the barracks yard; it’s raining, the water
makes the sand gleam; the few wretched trees drip and drip; the
men await some command with the watchfulness of well-trained
dogs; the water pours from their packs, the sergeant roars, the
corporals grit their teeth in zeal and rage; but you? With a monotony
like that of the drops that trickle from your cap, you think: ‘What will
to-night be like? And to-morrow morning? And to-morrow night?’
And the whole year lies ahead of you like a soaked and muddy road.
You think of your desolate room with its three dozen books, the
meaningless pictures, and the carpet worn thin by many feet; you
think of the report you’ve got to hand in, and the canteen accounts
you’ve got to audit, and the stable inspection, and the next
regimental ball, where the arrogant wives of your superior officers
will bore you to the point of illness with their shallow talk; you think
your way through the whole circle of your life, and find nothing but
what is trivial and cheerless as a rainy day. Is that endurable?
“One day I put the question to myself: What was I really
accomplishing, and what was the nature of my reward? The answer
was that, from a human and intellectual point of view, my
accomplishment was an absolute zero. My reward consisted of a
number of privileges, the sum of which raised me very high in the
social scale, but gave me this position only at the cost of
surrendering my personality wholly. I had to obey my superiors and
to command my inferiors. That was all. The power to command was
conditioned in the duty to obey. And each man in the service,
whatever his station, is bound in the identical way, and is simply a
connective apparatus in a great electrical circuit. Only the humblest,
the great mass of privates, were confined to obedience. The ultimate
responsibility at the very top was lost in the vague. In spite of its
ultimate primitiveness, the structure of every military organization
has a mystery at its core. But between the arbitrary will of a very
few and the touching and incomprehensible humility of the great
mass, the parts function according to iron laws. Whoever refuses to
function, or rebels, is crushed.
“There are those who assert that this compulsion has a moral effect
and subserves a higher conception of freedom. I was myself of that
opinion for a long time; but I did not find it permanently tenable. I
felt myself weakening, and a rebellion seething in my blood. I pulled
myself together, and fought against criticism and doubt. In vain.
Something had gone out of me. I lost the readiness to obey and the
security to command. It was torment. Above me I saw implacable
idols, below me defenceless victims. I myself was both idol and
victim, implacable and defenceless at once. It seemed to me that
humanity ceased where the circle of my activity began. My life
seemed to me no longer a part of the general life of mankind, but a
fossilized petrefaction conditioned in certain formulæ of command
and obedience.
“This condition could, of course, not remain hidden. My comrades
withdrew their confidence from me. I was observed and distrusted.
Before I had time to clarify either my mind or my affairs, an incident
occurred which forced me to a decision. A fellow officer in my
regiment, Captain von Otto, was engaged to the daughter of an
eminent judge. The wedding, although the date had been set, could
not take place. Otto had a slight attack of pulmonary trouble and
had to go South for cure. About four weeks after his departure,
there was a celebration in honour of the emperor’s birthday, and
among the ladies invited was the captain’s betrothed. Everybody was
rather gay and giddy that evening, especially a dear friend of mine,
Georg Mattershausen, a sincere, kindly chap who had just received a
promotion in rank. The captain’s betrothed, who had been his
neighbour at table, was infected by his merriment, and on the way
home he begged her for a kiss. She refused, and he was going to
steal one. She now grew very serious; he at once came to his
senses, apologized with the utmost sincerity, and, at the very door of
her paternal house, received her solemn promise to mention the
incident to no one. When, however, seventeen weeks later, Captain
von Otto returned, the girl was seized by some queer scruple, and
thought it her duty to tell him of the incident between herself and
Mattershausen. The result was a challenge. The conditions were
extraordinarily severe: ten paces distance, drawn revolvers, half a
minute to aim, exchange of shots to the disablement of either
combatant. I was Mattershausen’s second. Otto, who had held
himself to be affronted and had sent the challenge, had the first
shot. He aimed carefully at the head of his adversary. I saw that. But
the bullet whistled past my friend’s ear. Mattershausen aimed, but
his revolver did not go off. This was counted a shot. New pistols
were brought. Otto aimed as carefully as before and this time shot
Mattershausen straight through the heart. Death was immediate.
“I wonder whether you, too, think that that was a harsh punishment
for a moment of youthful thoughtlessness and impropriety. To me it
seemed terribly harsh. I felt profoundly that a crime had been
committed against my friend. Our fossilized caste had perpetrated a
murder. Two days later, in the officers’ mess, I expressed this opinion
quite frankly. There was general astonishment. One or two sharp
replies were made. Some one asked me what I would have done in
such a situation. I answered that I would certainly not have sent a
challenge, that I could never approve a notion of honour so morbid
and self-centred as to demand a human life for a trifle. Even if the
young girl’s over-tender conscience had persuaded her to break her
promise, I would have caused no further trouble, and let the little
incident glide into forgetfulness. At that there was general
indignation—a great shaking of heads, angry or troubled faces, an
exchange of significant glances. But I kept on. Mattershausen’s
wretched end had hit me damned hard, and I relieved my whole
mind. So I added that, if I had been in Mattershausen’s place, I
would have refused the challenge, quite regardless of consequences.
That statement fell among them like a bomb, and a painful silence
followed. ‘I imagine you would have reconsidered,’ said the ranking
major, ‘I don’t think you would have disregarded all the
consequences.’ ‘All,’ I insisted, ‘certainly, all!’ At that moment Captain
von Otto, who had been sitting at another table, arose, and asked
frostily: ‘You would have risked the odium of cowardice?’ I too arose,
and answered: ‘Under such circumstances I would have risked that
too.’ Captain von Otto smiled a contorted smile, and said with an
emphasis that could not be misinterpreted: ‘Then I don’t understand
your sitting at the same table with officers of His Majesty.’ He bowed
stiffly, and went out.
“The die had been cast. No one was curious as to what I would do;
no one doubted but that there was only one thing left for me to do.
But I was determined to push the matter to its logical conclusion.
That super-idol, known as the code of honour, had issued its decree;
but I was determined to refuse obedience and take the
consequences upon myself. That very evening, when I came home,
two comrades were awaiting me to offer me their services. I refused
courteously. They looked at me as though I had gone mad, and
went off in absurd haste.
“The inevitable consequences followed. You can understand that I
could no longer breathe in that air. You cannot outrage the fetishes
of your social group and go unpunished. I had to avoid insult, and
learned what it was to be an outcast. And that is bad. The
imagination alone cannot quite grasp the full horror of it. I saw
clearly that there was no place left for me in my fatherland. The way
out was obvious.”
Christian had listened to his friend’s story with unmoved
countenance. He got up, took a few turns through the room, and
returned to his seat. Then he said: “I think you did the right thing. I
am sorry you must leave us, but you did right.”
Stettner looked up. How strange that sounded: You did right. A
question hovered on his lips. But it was not uttered. For Christian
feared that question, and silenced it by a sudden conventionality of
demeanour.
XIV
Christian, the brothers Maelbeek, who had followed Eva from
Holland, Botho von Thüngen, a Russian councillor of state named
Koch, and Crammon sat at luncheon in the dining hall of the hotel.
They were talking about a woman of the streets who had been
murdered. The police had already caught the murderer. He was a
man who had once belonged to good society, but had gradually
gone to the dogs. He had throttled the woman and robbed her in a
sailor’s tavern.
Now all the prostitutes in the city had unanimously determined to
show their sister, who had sacrificed her life to her calling, a last and
very public mark of respect, and to follow her coffin to the grave.
The respectable citizens of Hamburg felt this to be a sort of
challenge and protested. But there was no legal provision by which
the demonstration could be stopped.
“We ought to see the spectacle,” said Crammon, “even if we have to
sacrifice our siesta.”
“Then there’s no time to be lost,” the elder Maelbeek declared, and
looked at his watch. “The friends will assemble at the house of
mourning at three sharp.” He smiled, and thought this way of putting
the matter rather witty.
Christian said that he would go too. The motor took them to a
crossing that had been closed by the police. Here they left the car,
and Herr von Thüngen persuaded the police captain to let them
pass.
They were at once surrounded by a great throng of humble folk—
sailors, fishermen, workingmen, women, and children. The windows
of the houses were thronged with heads. The Maelbeeks and Koch
stopped here, and called Thüngen to join them. Christian walked
farther. Somehow the behaviour of his companions irritated him. He
felt the kind of curiosity which filled them as something
disagreeable. He was curious too, but in another way. Or, at least, it
seemed different to him.
Crammon remained by his side. But the throng grew rowdy. “Where
are you going?” Crammon asked peevishly. “There is no use in going
farther. Let us wait here.”
Christian shook his head.
“Very well. I take my stand here,” Crammon decided, and separated
from Christian.
The latter made his way up to the dirty, old house at the door of
which the hearse was standing. It was a foggy day. The black wagon
was like a dark hole punched into the grey. Christian wanted to go a
little farther, but some young fellows purposely blocked his way.
They turned their heads, looked him over, and suspected him of
being a “toff.” Their own garb was cheap and flashy; their faces and
gestures made it clear what trade they drove. One of them was a
young giant. He was half a head taller than Christian, and his brows
joined over the bridge of his nose. On the index finger of his left
hand he wore a huge carnelian ring.
Christian looked about him quite unintimidated. He saw hundreds of
women, literally hundreds, ranging in age from sixteen to fifty, and
in condition from bloom to utter decay, and from luxury to rags and
filth.
They had all gathered—those who had passed the zenith of their
troubled course, and those who had barely emerged from childhood,
frivolous, sanguine, vain, and already tainted with the mire of the
great city. They had come from all streets; they were recruited from
all nations and all classes; some had escaped from a sheltered
youth, others had risen from even direr depths; there were those
who felt themselves pariahs and had the outcast’s hatred in their
eyes, and there were others who showed a certain pride in their
calling and held themselves aloof. He saw cynical and careworn
faces, lovely and hardened ones, indifferent and troubled, greedy
and gentle faces. Some were painted and some pallid; and the latter
seemed strangely naked.
He was familiar with them from the streets and houses of many
cities, as every man is. He knew the type, the unfailing stamp, the
acquired gesture and look—this hard, rigid, dull, clinging, lightless
look. But he had never before seen them except when they were
exercising their function behind the gates of their calling,
dissembling their real selves and under the curse of sex. To see
many hundreds of them separated from all that, to see them as
human beings stripped of the stimulus and breath of a turbid
sexuality—that was what seemed to sweep a cloud from his eyes.
Suddenly he thought: “I must order my hunting lodge to be sold,
and the hounds too.”
The coffin was being carried from the house. It was covered with
flowers and wreaths; and from the wreaths fluttered ribands with gilt
inscriptions. Christian tried to read the inscriptions, but it was
impossible. The coffin had small, silver-plated feet that looked like
the paws of a cat. By some accident one of these had been broken
off, and that touched Christian, he hardly knew why, as unbearably
pitiful. An old woman followed the coffin. She seemed more vexed
and angry than grief-stricken. She wore a black dress, but the seam
under one arm was ripped open. And that too seemed unbearably
pitiful.
The hearse started off. Six men carrying lighted candles walked in
front of it. The murmur of voices became silent. The women,
walking by fours, followed the hearse. Christian stood still close
pressed against a wall, and let the procession pass him by. In a
quarter of an hour the street was quite desolate. The windows of the
houses were closed. He remained alone in the street, in the fog.
As he walked away he reflected: “I’ve asked my father to take care
of my collection of rings. There are over four thousand of them, and
many are beautiful and costly. They could be sold too. I don’t need
them. I shall have them sold.”
He wandered on and on, and lost all sense of the passing of time.
Evening came, and the city lights glowed through the fog.
Everything became moist, even to the gloves on his hands.
He thought of the missing foot on the coffin of the murdered harlot,
and of the torn seam of the old woman’s dress.
He passed over one of the great bridges of the Elbe, and then
walked along the river bank. It was a desolate region. He stopped
near the light of a street lamp, gazed into the water, drew forth his
wallet, took out a bank note of a hundred marks, turned it about in
his hands, shook his head, and then, with a gesture of disgust,
threw it into the water. He took a second and did the same. There
were twenty bank notes in his wallet. He took them out one by one,
and with that expression half of disgust, half of dreaminess, he let
them glide into the river.
The street lamps illuminated the inky water for a short distance, and
he saw the bank notes drift away.
And he smiled and went on.
XV
When he reached the hotel he felt an urgent need of warmth. By
turns he entered the library, the reception hall, the dining-room. All
these places were well heated, but their warmth did not suffice him.
He attributed his chill to walking so long in the damp.
He took the lift and rode up to his own rooms. He changed his
clothes, wrapped himself warmly, and sat down beside the radiator,
in which the steam hissed like a caged animal.
Yet he did not grow warm. At last he knew that his shivering was not
due to the moisture and the fog, but to some inner cause.
Toward eleven o’clock he arose and went out into the corridor. The
stuccoed walls were divided into great squares by gilt moulding; the
floor was covered by pieces of carpet that had been joined together
to appear continuous. Christian felt a revulsion against all this false
splendour. He approached the wall, touched the stucco, and
shrugged his shoulders in contempt.
At the end of the long corridor was Eva’s suite. He had passed the
door several times. As he passed it again he heard the sound of a
piano. Only a few keys were being gently touched. After a moment’s
reflection he knocked, opened the door, and entered.
Susan Rappard was alone in the room. Wrapped in a fur coat, she
sat at the piano. On the music rack was propped a book that she
was reading. Her fingers passed with ghostly swiftness over the
keys, but she struck one only quite rarely. She turned her head and
asked rudely: “What do you want, Monsieur?”
Christian answered: “If it’s possible, I should like to speak to
Madame. I want to ask her a question.”
“Now? At night?” Susan was amazed. “We’re tired. We’re always
tired at night in this hyperborean climate, where the sun is a legend.
The fog weighs on us. Thank God, in four days we have our last
performance. Then we’ll go where the sky is blue. We’re longing for
Paris.”
“I should be very happy if I could see Madame,” Christian said.
Susan shook her head. “You have a strange kind of patience,” she
said maliciously. “I hadn’t suspected you of being so romantic. You’re
pursuing a very foolish policy, I assure you. Go in, if you want to,
however. Ce petit laideron est chez elle, demoiselle Schöntag. She
acts the part of a court fool. Everything in the world is amusing to
her—herself not least. Well, that is coming to an end too.”
Voices and clear laughter could be heard. The door of Eva’s rooms
opened, and she and Johanna appeared on the threshold. Eva wore
a simple white garment, unadorned but for one great chrysoprase
that held it on the left shoulder. Her skin had an amber gleam, the
quiver of her nostrils betrayed a secret irritation. The beautiful
woman and the plain one stood there side by side, each with an
acute feminine consciousness of her precise qualities: the one vital,
alluring, pulsing with distinction and freedom; the other all adoration
and yearning ambition for that vitality and that freedom.
Tenderly and delicately Johanna had put her arm about Eva and
touched her friend’s bare shoulder with her cheek. With her bizarre
smile she said: “No one knows how it came that Rumpelstilzkin is my
name.”
They had not yet observed Christian. A gesture of Susan’s called
their attention to him. He stood in the shadow of the door. Johanna
turned pale, and her shy glance passed from Eva to Christian. She
released Eva, bowed swiftly to kiss Eva’s hand, and with a whispered
good-night slipped past Christian.
Although Christian’s eyes were cast down, they grasped the vision of
Eva wholly. He saw the feet that he had once held naked in his
hands; under her diaphanous garment he saw the exquisite firmness
of her little breasts; he saw the arms that had once embraced him
and the perfect hands that had once caressed him. All his bodily
being was still vibrantly conscious of the smoothness and delicacy of
their touch. And he saw her before him, quite near and hopelessly
unattainable, and felt a last lure and an ultimate renunciation.
“Monsieur has a request,” said Susan Rappard mockingly, and
preparing to leave them.
“Stay!” Eva commanded, and the look she gave Christian was like
that she gave a lackey.
“I wanted to ask you,” Christian said softly, “what is the meaning of
the name Eidolon by which you used to call me. My question is
belated, I know, and it may seem foolish to-day.” He smiled an
embarrassed smile. “But it torments me not to know when I think
about it, and I determined to ask you.”
Susan gave a soundless laugh. In its belated and unmotivated
urgency, the question did, indeed, sound a little foolish. Eva seemed
amused too, but she concealed the fact. She looked at her hands
and said: “It is hard to tell you what it means—something that one
sacrifices, or a god to whom one sacrifices, a lovely and serene
spirit. It means either or perhaps both at once. Why remind
ourselves of it? There is no Eidolon any more. Eidolon was shattered,
and one should not exhibit the shards to me. Shards are ugly
things.”
She shivered a little, and her eyes shone. She turned to Susan. “Let
me sleep to-morrow till I wake. I have such evil dreams nowadays,
and find no rest till toward morning.”
XVI
Passing back through the corridor Christian saw a figure standing
very still in the semi-darkness. He recognized Johanna, and he felt
that this thing was fated—that she should be standing here and
waiting for him.
She did not look at him; she looked at the floor. Not until he came
quite close to her did she raise her eyes, and then she looked timidly
away. Her lips quivered. A question hovered on them. She knew all
that had passed between Eva and Christian. That they had once
been lovers only increased her enthusiastic admiration for them
both. But what happened between them now—her brief presence
made her sure of its character—seemed to her both shameful and
incomprehensible.
She was imaginative and sensitive, and loved those who were nobly
proud; and she suffered when such noble pride and dignity were
humbled. Her whole heart was given over to her ideal of spiritual
distinction. Sometimes she would misunderstand her own ideal, and
take external forms and modes as expressions of it. And this division
in her soul, to which she was not equal, sometimes delivered her
into the power of mere frivolity. “It is late,” she whispered timidly. It
was not a statement; it was an attempt to save herself. Each time
that Christian had been mentioned, three things had struck her
mind: his elegance, his fine pride, his power over all hearts. That
was the combination that called to her and stirred her and filled her
days with longing.
Thus she had followed Crammon in search of the great adventure,
although she had said of him but an hour after she had met him:
“He is grandiosely and grotesquely comic.” She had followed him like
a slave to a market of slaves, hoping to catch the eye of the khalif.
But she had no faith in her own power. Voluntarily and intentionally
she crumbled the passions of her being into small desires. She
suffered from that very process and jeered at herself. She was too
timid to take greatly what she wanted. She nibbled at life and had
not the adventurousness of great enjoyments. And she mocked at
her own unhappy nature, and suffered the more.
And now he stood before her. It frightened and surprised her, even
though she had waited for him. Since he stayed, she wanted to think
him bold and brave. But she could not, and at once she shrank into
self-contempt. “It is late,” she whispered again, nodded a good-
night, and opened the door of her room.
But Christian begged silently with an expression that was irresistible.
He crossed the threshold behind the trembling girl. Her face grew
hard. But she was too fine to play a coquettish game. Before her
blood was stirred her eyes had yielded. The pallor of her face lit it
with a new charm. There was no hint of plainness any more. The
stormy expectation of her heart harmonized the lines of her features
and melted them into softness, gentleness, and delicacy.
Of her power over the senses of men she was secure. She had
tested her magnetism on those whom one granted little and who
gave less. Flirtations had been used as anodynes in her social group.
One had played with false counters, and by a silent compact avoided
serious moments. But her experience failed her to-night, for here
there was not lightness but austerity. She yielded herself to this
night, oblivious of the future and its responsibilities.
XVII
Stephen Gunderam had to go to Montevideo. In that city there was a
German physician who had considerable skill in the treatment of
nervous disorders; and the bull-necked giant suffered from insomnia
and nocturnal hallucinations. Furthermore, there was to be a yacht
race at Montevideo, on the results of which Stephen had bet heavily.
He appointed Demetrios and Esmeralda as Letitia’s guardians. He
said to them: “If anything happens to my wife or she does anything
unseemly, I’ll break every bone in your bodies.” Demetrios grinned.
Esmeralda demanded that he bring her a box of sweets on his
return.
Their leave-taking was touching. Stephen bit Letitia’s ear, and said:
“Be true to me.”
Letitia immediately began to play upon the mood of her guardians.
She gave Demetrios a hundred pesos and Esmeralda a gold bracelet.
She corresponded secretly with the naval lieutenant, Friedrich Pestel.
An Indian lad, of whose secrecy and reliability she was sure, served
as messenger. Within a week Pestel’s ship was to proceed to Cape
Town, so there was little time to be lost. He did not think he would
be able to return to the Argentine until the following winter. And
Letitia loved him dearly.
Two miles from the estate there was an observatory in the lonely
pampas. A wealthy German cattle-man had built it, and now a
Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.
More than just a book-buying platform, we strive to be a bridge
connecting you with timeless cultural and intellectual values. With an
elegant, user-friendly interface and a smart search system, you can
quickly find the books that best suit your interests. Additionally,
our special promotions and home delivery services help you save time
and fully enjoy the joy of reading.
Join us on a journey of knowledge exploration, passion nurturing, and
personal growth every day!
ebookbell.com

More Related Content

PDF
JAVA U-1 Combined Notes_34691272.pdf Java
PDF
Core Java Vol 1 2 For The Impatient And Effective Pack 12th Ed Cay S Horstmann
PPTX
Fundamentals of java --- version 2
PDF
Learn java in one day and learn it well 2016 jamie chan
PDF
Essential Java For Scientists And Engineers 1st Brian D Hahn
PDF
Mastering Java A Beginners Guide Divya Sachdeva Natalya Ustukpayeva
PPTX
Core java programming tutorial - Brainsmartlabs
PDF
Java Developer Roadmap PDF By ScholarHat
JAVA U-1 Combined Notes_34691272.pdf Java
Core Java Vol 1 2 For The Impatient And Effective Pack 12th Ed Cay S Horstmann
Fundamentals of java --- version 2
Learn java in one day and learn it well 2016 jamie chan
Essential Java For Scientists And Engineers 1st Brian D Hahn
Mastering Java A Beginners Guide Divya Sachdeva Natalya Ustukpayeva
Core java programming tutorial - Brainsmartlabs
Java Developer Roadmap PDF By ScholarHat

Similar to Download full ebook of Programming With Java Edet Theophilus instant download pdf (20)

PDF
(eBook PDF) Java How to Program, Late Objects Global Edition 11th Edition
PPTX
Java in Mule
PPT
Chapter 1 java
PPTX
Journey-into-the-World-of-Java.pp3dqe23R3qtx
PPTX
Java For Begineers
 
PPTX
Java for beginners
PPTX
Java For Begineers
PDF
Java Programming.pdf
PPTX
Java Programming
 
PDF
Learning Java An Introduction to Real World Programming with Java Marc Loy
DOC
6010 java programming version 6
PPTX
Learning core java
PDF
Core Java An Integrated Approach 2nd R Nageswara Rao
PPTX
Java Programming
PDF
Learning Java An Introduction to Real World Programming with Java Marc Loy
PPTX
Java programming course for beginners
ODP
Learning java
PDF
1.Java_programming2017.pdf
PDF
Objectoriented Programming And Java 2nd Ed Danny C C Poo Derek Beng Kee Kiong...
PDF
Mastering Java: A Beginner's Guide 1st Edition Sufyan Bin Uzayr
(eBook PDF) Java How to Program, Late Objects Global Edition 11th Edition
Java in Mule
Chapter 1 java
Journey-into-the-World-of-Java.pp3dqe23R3qtx
Java For Begineers
 
Java for beginners
Java For Begineers
Java Programming.pdf
Java Programming
 
Learning Java An Introduction to Real World Programming with Java Marc Loy
6010 java programming version 6
Learning core java
Core Java An Integrated Approach 2nd R Nageswara Rao
Java Programming
Learning Java An Introduction to Real World Programming with Java Marc Loy
Java programming course for beginners
Learning java
1.Java_programming2017.pdf
Objectoriented Programming And Java 2nd Ed Danny C C Poo Derek Beng Kee Kiong...
Mastering Java: A Beginner's Guide 1st Edition Sufyan Bin Uzayr
Ad

Recently uploaded (20)

PDF
Computing-Curriculum for Schools in Ghana
PDF
LNK 2025 (2).pdf MWEHEHEHEHEHEHEHEHEHEHE
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Classroom Observation Tools for Teachers
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
Lesson notes of climatology university.
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PPTX
UNIT III MENTAL HEALTH NURSING ASSESSMENT
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
What if we spent less time fighting change, and more time building what’s rig...
PPTX
Radiologic_Anatomy_of_the_Brachial_plexus [final].pptx
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
01-Introduction-to-Information-Management.pdf
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PPTX
master seminar digital applications in india
PDF
Trump Administration's workforce development strategy
Computing-Curriculum for Schools in Ghana
LNK 2025 (2).pdf MWEHEHEHEHEHEHEHEHEHEHE
Final Presentation General Medicine 03-08-2024.pptx
Classroom Observation Tools for Teachers
Module 4: Burden of Disease Tutorial Slides S2 2025
Microbial diseases, their pathogenesis and prophylaxis
Lesson notes of climatology university.
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
UNIT III MENTAL HEALTH NURSING ASSESSMENT
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
What if we spent less time fighting change, and more time building what’s rig...
Radiologic_Anatomy_of_the_Brachial_plexus [final].pptx
Anesthesia in Laparoscopic Surgery in India
2.FourierTransform-ShortQuestionswithAnswers.pdf
Supply Chain Operations Speaking Notes -ICLT Program
01-Introduction-to-Information-Management.pdf
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
master seminar digital applications in india
Trump Administration's workforce development strategy
Ad

Download full ebook of Programming With Java Edet Theophilus instant download pdf

  • 1. Programming With Java Edet Theophilus download https://ebookbell.com/product/programming-with-java-edet- theophilus-55229942 Explore and download more ebooks at ebookbell.com
  • 2. Here are some recommended products that we believe you will be interested in. You can click the link to download. Programming With Java A Primer 3e 3rd E Balaguruswamy https://ebookbell.com/product/programming-with-java-a-primer-3e-3rd-e- balaguruswamy-34093360 Programming With Java A Primer 3rd Edition E Balagurusamy https://ebookbell.com/product/programming-with-java-a-primer-3rd- edition-e-balagurusamy-5411388 Beginning Programming With Java For Dummies 6th Barry Burd https://ebookbell.com/product/beginning-programming-with-java-for- dummies-6th-barry-burd-47641808 Soap Programming With Java William B Brogden Bill Brogden https://ebookbell.com/product/soap-programming-with-java-william-b- brogden-bill-brogden-2169302
  • 3. Beginning Programming With Java For Dummies Third Edition 3rd Edition Barry Burd https://ebookbell.com/product/beginning-programming-with-java-for- dummies-third-edition-3rd-edition-barry-burd-22628250 Beginning Programming With Java For Dummies Second Edition 2nd Edition Barry A Burd https://ebookbell.com/product/beginning-programming-with-java-for- dummies-second-edition-2nd-edition-barry-a-burd-33312102 Beginning Programming With Java For Dummies Fourth Edition 4th Barry A Burd https://ebookbell.com/product/beginning-programming-with-java-for- dummies-fourth-edition-4th-barry-a-burd-4924178 Beginning Programming With Java For Dummies 5th Barry Burd https://ebookbell.com/product/beginning-programming-with-java-for- dummies-5th-barry-burd-6723376 Reactive Programming With Java 9 Build Asynchronous Applications With Rxjava 20 Flow Api And Spring Webflux Tejaswini Mandar Jog https://ebookbell.com/product/reactive-programming-with-java-9-build- asynchronous-applications-with-rxjava-20-flow-api-and-spring-webflux- tejaswini-mandar-jog-6865226
  • 6. Programming With Java By Theophilus Edet Theophilus Edet [email protected] facebook.com/theoedet twitter.com/TheophilusEdet Instagram.com/edettheophilus
  • 7. Copyright © 2023 Theophilus Edet All rights reserved. No part of this publication may be reproduced, distributed, or transmitted in any form or by any means, including photocopying, recording, or other electronic or mechanical methods, without the prior written permission of the publisher, except in the case of brief quotations embodied in reviews and certain other non-commercial uses permitted by copyright law.
  • 8. Table of Contents Preface Programming With Java Module 1: Introduction to Java Programming What is Java and its Significance Installing and Setting Up Java Development Environment Writing Your First Java Program Understanding the Java Virtual Machine (JVM) Module 2: Variables and Data Types in Java Declaring and Initializing Variables Java's Primitive Data Types: int, float, boolean, etc. Type Casting and Conversion in Java Variable Scope and Lifetime in Java Module 3: Basic Input and Output in Java Using System.out.println and System.out.print for Output Reading User Input with Scanner Class Formatting Output with printf Debugging Techniques in Java Module 4: Operators and Expressions in Java Arithmetic, Relational, and Logical Operators Operator Precedence and Associativity Using Operators for Expressions in Java Bitwise Operators and Manipulation Module 5: Control Flow and Conditional Statements Using if, else, and else if Statements Ternary Operator for Conditional Expressions Switch Statements for Multiple Choices Handling Conditions and Creating Logical Flows Module 6: Loops and Iteration in Java while and do-while Loops for Iteration Using for Loop for Controlled Iteration Loop Control: break, continue, and return Iterating Over Arrays and Collections Module 7: Arrays and Array Manipulation in Java Creating and Manipulating Arrays Accessing and Modifying Array Elements Array Methods: length, clone, Arrays class Multi-Dimensional Arrays and Nested Arrays Module 8: Introduction to Functions in Java Writing and Defining Methods in Java Method Parameters and Return Values Method Overloading and Variadic Methods Scoping and Method Call Stack in Java Module 9: Control Structures and Flow Control in Java Applying Control Structures: if-else, switch Using for and while Loops
  • 9. The Enhanced for Loop and Iterators Applying Flow Control Techniques in Java Module 10: Strings and String Manipulation in Java Creating and Manipulating Strings String Concatenation and Formatting String Methods: charAt, substring, length String Equality and Comparison in Java Module 11: Introduction to Object-Oriented Programming (OOP) Understanding OOP Concepts: Abstraction, Encapsulation, Inheritance, Polymorphism Creating Classes and Objects in Java Defining Attributes and Methods in Classes Access Modifiers and Encapsulation in Java Module 12: Methods and Constructors in Java Writing Methods in Java Method Overloading and Method Signature Constructors and Constructor Overloading Using this and Constructor Chaining Module 13: Class Relationships and Inheritance in Java Understanding Inheritance in Java Creating Subclasses and Superclasses Method Overriding and @Override Annotation Polymorphism and Dynamic Method Dispatch Module 14: Access Modifiers and Encapsulation in Java Public, Protected, Default, and Private Access Modifiers Encapsulation and Data Hiding in Java Getter and Setter Methods Best Practices for Access Modifiers Module 15: Abstract Classes and Interfaces in Java Declaring and Defining Abstract Classes Implementing Interfaces in Java Multiple Inheritance with Interfaces When to Use Abstract Classes vs. Interfaces Module 16: Exception Handling and Error Management in Java Introduction to Exception Handling Using try, catch, and finally Blocks Throwing and Catching Exceptions Creating Custom Exception Classes Module 17: Introduction to Collections Framework in Java Overview of Java Collections Framework Working with ArrayList and LinkedList Using HashSet, LinkedHashSet, and TreeSet Collections Algorithms and Sorting Module 18: Lists, Sets, and Maps in Java Working with List Interface: ArrayList and LinkedList Using Set Interface: HashSet, LinkedHashSet, and TreeSet Understanding Map Interface: HashMap, LinkedHashMap, and TreeMap Iterating and Manipulating Collections Module 19: Generics and Type-Safe Collections in Java Introduction to Generics in Java Writing Generic Classes and Methods
  • 10. Using Generic Collections: List<E>, Set<E>, Map<K,V> Type Erasure and Wildcards Module 20: Introduction to Threads and Concurrency in Java Understanding Threads and Multithreading Creating Threads with Thread Class and Runnable Interface Thread States and Synchronization Thread Safety and Race Conditions Module 21: Synchronization and Locks in Java Understanding Synchronization and Critical Sections Using synchronized Keyword Using Locks: ReentrantLock and ReadWriteLock Deadlocks and Avoiding Race Conditions Module 22: Introduction to Input/Output (I/O) in Java File I/O Basics: Reading and Writing Files Using File and FileWriter/FileReader Classes Byte Streams and Character Streams Using BufferedReader and BufferedWriter Module 23: Networking and Socket Programming in Java Introduction to Networking in Java Creating TCP and UDP Sockets Implementing Server and Client Applications Handling Network Errors and Exceptions Module 24: Introduction to GUI Programming with Swing Building Graphical User Interfaces (GUIs) in Java Creating GUI Components: JFrame, JPanel, JButton Event Handling and Listener Interfaces Layout Managers and Designing Uis Module 25: Working with GUI Components and Layouts Using Text Components: JTextField, JTextArea Creating Lists, Tables, and Combo Boxes Using Layout Managers: FlowLayout, BorderLayout, GridLayout Building Complex UIs and Windows Module 26: File Handling and Serialization in Java Serialization and Deserialization Concepts Implementing Serialization with Serializable Interface Writing and Reading Objects to/from Files Handling Object Versioning and Compatibility Module 27: Introduction to JavaFX for Modern UI Development Introduction to JavaFX Framework Building UI with Scene Graph and Nodes Using CSS for Styling JavaFX Applications Creating Animation and Transitions Module 28: Database Connectivity with JDBC Introduction to JDBC (Java Database Connectivity) Connecting to Databases with DriverManager Executing SQL Queries and Statements Handling ResultSets and Performing CRUD Operations Module 29: Java Collections Framework in Depth Deeper Dive into Collections Framework Working with Queue Interface and Implementations
  • 11. Using Map Interface and Advanced Map Operations Java Streams API and Functional Programming Module 30: Building Java Applications and Final Project Structuring a Java Project: Packages and Modules Implementing a Java Application Testing and Debugging Java Applications Building a Final Project and Creating a Portfolio Review Request Embark on a Journey of ICT Mastery with CompreQuest Books
  • 12. Preface Welcome to "Programming With Java," a comprehensive guide designed to empower both novice and seasoned developers on their journey through the dynamic realm of Java programming. In this preface, we embark on a journey to explore the paradigms, programming models, and diverse applications that make Java a powerhouse in the world of software development. Java: A Versatile and Ubiquitous Programming Language Java, since its inception by Sun Microsystems in the mid-1990s, has stood the test of time as a versatile, platform-independent, and widely adopted programming language. Its ability to run on diverse platforms without modification, thanks to the "Write Once, Run Anywhere" (WORA) philosophy, has made it a staple in a multitude of domains, from web development to enterprise solutions. Object-Oriented Paradigm: The Foundation of Java's Power At the heart of Java's elegance is its commitment to the object-oriented paradigm. By embracing encapsulation, inheritance, and polymorphism, Java provides developers with a robust and modular structure for building scalable and maintainable software. This paradigm encourages code reusability, fosters modular design, and enables the construction of complex systems through the composition of well-defined objects. Procedural and Functional Programming: Expanding the Toolkit While rooted in object-oriented principles, Java is not confined to a single paradigm. It seamlessly integrates procedural and functional programming features, offering developers the flexibility to choose the paradigm that best suits their problem-solving needs. This versatility allows for the development of concise, expressive code, further enhancing Java's appeal across various application domains. Key Programming Models Supported by Java
  • 13. "Programming With Java" unfolds with an exploration of the core programming models that Java supports: 1. Application Programming: Java excels in building standalone applications, ranging from desktop utilities to complex enterprise solutions. The language's extensive standard library, coupled with powerful development frameworks, empowers developers to create robust and feature-rich applications. 2. Web Development: Java has left an indelible mark on web development, with frameworks like Spring and JavaServer Faces (JSF) facilitating the creation of scalable and maintainable web applications. The ability to build dynamic and interactive web interfaces has made Java a preferred choice for enterprises and startups alike. 3. Mobile Development: Through platforms like Android, Java has become synonymous with mobile application development. The Android SDK leverages Java's capabilities, enabling developers to craft innovative and resource-efficient mobile applications for a global audience. 4. Enterprise Solutions: Java's prowess in developing enterprise- level solutions is showcased through technologies like Java EE (Enterprise Edition). This model provides a robust infrastructure for building scalable and distributed systems, making it a go-to choice for large-scale applications. 5. Cloud Computing: Java's compatibility with cloud computing platforms and frameworks, such as Spring Cloud, positions it as a formidable player in the era of cloud-native applications. Java's ability to seamlessly integrate with cloud services enhances its relevance in the ever-evolving landscape of cloud computing. Applications of Java in the Modern World The subsequent chapters of this book delve into real-world applications of Java across diverse industries. From financial services and healthcare to e-
  • 14. commerce and game development, Java's adaptability shines through. Its reliability, performance, and the vast ecosystem of libraries and frameworks contribute to its sustained popularity in mission-critical applications. Navigating "Programming With Java" "Programming With Java" is crafted with a pedagogical approach, ensuring that readers, whether beginners or experienced developers in other languages, can seamlessly grasp Java's intricacies. The book adopts a structured progression, beginning with fundamental concepts, progressing through advanced topics, and culminating in the development of a final project. As you embark on this educational journey, embrace the challenges and discoveries that come with mastering Java. Whether you're aiming to build enterprise-level applications, explore mobile development, or contribute to the vibrant world of open-source projects, "Programming With Java" serves as your compass, guiding you through the diverse landscape of Java programming. Let the exploration begin! Theophilus Edet
  • 15. Programming With Java In the dynamic landscape of computer programming, Java stands as a stalwart language, renowned for its versatility, portability, and extensive applications across a myriad of domains. "Programming With Java" serves as an indispensable guide for both novice and experienced programmers, offering a comprehensive exploration of Java's intricacies and practical applications. Java's Ubiquity in Programming Java's significance in the programming world cannot be overstated. Born out of the vision to create a platform-independent language, Java has become ubiquitous in various software ecosystems. Its "write once, run anywhere" philosophy has empowered developers to create applications that seamlessly run on diverse platforms, from embedded systems to enterprise servers. The book navigates through Java's evolution, delving into its historical roots and tracing the journey that has made it a cornerstone in modern software development. Applications Across Industries "Programming With Java" unravels the myriad applications of Java across industries, showcasing its adaptability and robustness. From mobile application development with Android to web-based solutions and enterprise-level systems, Java's versatility makes it a go-to choice for developers addressing diverse challenges. The book provides real-world examples and case studies, illustrating how Java serves as the backbone for crafting solutions that power the digital realm. Programming Models and Paradigms Java accommodates a spectrum of programming models and paradigms, making it a language of choice for developers with varying preferences and project requirements. The book delves into object-oriented programming (OOP), emphasizing Java's robust support for encapsulation, inheritance, and polymorphism. It explores the concurrent programming capabilities of Java, showcasing how developers can harness threads and concurrency utilities to build responsive and efficient applications.
  • 16. Java's Support for Modern Development Practices As the programming landscape continues to evolve, "Programming With Java" addresses Java's embrace of modern development practices. The book explores Java's compatibility with functional programming, introducing readers to lambda expressions and the Stream API. It highlights Java's role in supporting modular programming through the introduction of the Java Platform Module System (JPMS), enabling developers to create scalable and maintainable codebases. In conclusion, "Programming With Java" serves as an invaluable companion for those embarking on a journey into Java programming or seeking to deepen their understanding of this powerful language. Through its exploration of applications, programming models, and paradigms, the book equips readers with the knowledge to leverage Java's capabilities in crafting robust and innovative software solutions. Whether a novice or an experienced developer, this book is a gateway to mastering Java and unleashing its potential in the ever-evolving world of programming.
  • 17. Module 1: Introduction to Java Programming Within the broader context of "Programming With Java," the module titled "Introduction to Java Programming" serves as the foundational cornerstone, providing readers with a comprehensive initiation into the world of Java. This module is meticulously designed to cater to learners at various levels of expertise, offering a structured approach to understanding Java's syntax, concepts, and fundamental principles. Navigating the Java Landscape The module commences by guiding readers through an exploration of the Java programming language's landscape. It elucidates the historical context of Java, tracing its origins and evolution. By understanding the language's inception, readers gain insights into the design principles that have shaped Java into the versatile and widely adopted programming language it is today. This historical perspective sets the stage for a deeper dive into the technical aspects of Java programming. Grasping Java Syntax and Structure "Introduction to Java Programming" places a strong emphasis on demystifying Java's syntax and structure. The module systematically introduces key programming constructs, such as variables, data types, control flow statements, and functions. Through clear explanations and illustrative examples, readers are equipped with the essential building blocks to write simple yet effective Java programs. The module lays the groundwork for a solid understanding of the language's core elements, preparing learners for more advanced concepts. Object-Oriented Programming Principles
  • 18. Central to Java's identity is its strong adherence to object-oriented programming (OOP) principles. This module delves into the heart of OOP, unraveling concepts like classes, objects, inheritance, encapsulation, and polymorphism. Through hands-on exercises and practical examples, readers not only comprehend the theoretical underpinnings of OOP but also develop the skills to apply these principles in crafting efficient and maintainable Java code. Hands-On Learning with Java Exercises "Introduction to Java Programming" adopts a hands-on learning approach, recognizing the importance of practical application in reinforcing theoretical knowledge. The module is interspersed with coding exercises and challenges that encourage readers to actively engage with the material. These exercises serve as opportunities to implement newfound knowledge, solidify understanding, and cultivate problem-solving skills—a crucial aspect of becoming proficient in Java programming. Building a Foundation for Advanced Concepts Beyond laying the groundwork for Java basics, this module aspires to instill a sense of confidence in learners, setting the stage for more advanced topics covered in subsequent sections of the book. By the module's conclusion, readers are equipped with the requisite skills to embark on the journey of exploring Java's diverse applications, programming models, and paradigms, as outlined in the broader context of "Programming With Java." What is Java and its Significance The "What is Java and its Significance?" section within the "Introduction to Java Programming" module of "Programming With Java" initiates readers into the fundamental nature and pivotal role of Java in the programming realm. Java, characterized as a high-level, object-oriented programming language, serves as a robust platform for developers to construct a diverse array of applications. Its crowning feature, the "write once, run anywhere" capability, signifies that Java code, once compiled, can execute seamlessly on any device boasting a Java Virtual Machine (JVM). This intrinsic quality has significantly propelled Java's widespread adoption, cementing its importance in various computing environments.
  • 19. Java Syntax Demystified A thorough understanding of Java's syntax forms the crux of this section, unraveling the language's fundamental building blocks. For instance, variable declarations in Java echo a familiar syntax: // Java Syntax int myNumber = 42; String greeting = "Hello, Java!"; By delving into such code snippets, readers gain a hands-on appreciation of Java's syntax, providing a solid foundation for subsequent programming endeavors. This approach aims to demystify the intricacies of Java for learners, especially those transitioning from other languages, making the assimilation of concepts more accessible. Platform Independence: Java's Distinct Paradigm Integral to Java's significance is its unique approach to achieving platform independence. The section elucidates the process whereby Java source code undergoes compilation into bytecode, a platform- neutral intermediate representation. This bytecode is then executed by the Java Virtual Machine (JVM), allowing Java applications to transcend platform constraints effortlessly. The paradigm of platform independence positions Java as a language capable of running on diverse devices without modification. Such adaptability has solidified Java's role in the development of mobile applications, web services, and scalable enterprise-level systems. Versatility and Ecosystem Strength The significance of Java extends beyond syntax and platform independence to encompass its versatile ecosystem. Readers are introduced to the myriad applications of Java, ranging from Android application development to server-side programming. The section navigates through Java's robust libraries, frameworks, and vibrant community, illustrating how these elements collectively contribute to the language's adaptability in an ever-evolving technological landscape. Java's versatility is underscored by its resilience and
  • 20. enduring relevance, making it a cornerstone for programmers globally as they explore the multifaceted realms of software development. Installing and Setting Up Java Development Environment In the "Introduction to Java Programming" module of "Programming With Java," the section dedicated to "Installing and Setting Up Java Development Environment" serves as the gateway for readers to actively engage with Java programming. This essential phase involves preparing the development environment, ensuring a seamless transition from theory to practical application. Downloading and Installing the Java Development Kit (JDK) The first step in embarking on the Java programming journey is to download and install the Java Development Kit (JDK). The book guides readers through this process, emphasizing the importance of choosing the appropriate JDK version for their specific development needs. A typical Java installation involves setting system variables, such as JAVA_HOME and PATH, to enable the system to locate the Java binaries. // Setting JAVA_HOME and PATH in a bash environment (Linux/macOS) export JAVA_HOME=/path/to/your/jdk export PATH=$JAVA_HOME/bin:$PATH Such details provide readers with a practical understanding of the configuration steps, ensuring they can seamlessly set up their development environment. Configuring Integrated Development Environment (IDE) The section goes on to explore the advantages of using Integrated Development Environments (IDEs) for Java development. Popular IDEs like Eclipse or IntelliJ IDEA streamline the development process with features such as code completion, debugging tools, and project management. The book offers step-by-step instructions on installing and configuring these IDEs, empowering readers to choose the environment that aligns with their preferences and workflow. // Configuring Eclipse IDE with JDK
  • 21. 1. Open Eclipse 2. Navigate to Window > Preferences > Java > Installed JREs 3. Add the JDK installation path 4. Set the added JDK as the default JRE for the workspace By delving into the specifics of IDE configuration, the book ensures that readers not only install Java but also optimize their development environment for efficiency and productivity. Verifying the Java Installation To validate the successful setup of the Java development environment, the section concludes with instructions on verifying the Java installation. Readers are guided on executing a simple Java program—perhaps the ubiquitous "Hello, World!"—to confirm that the JDK and IDE configurations are accurate. // Hello, World! in Java public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World!"); } } Through hands-on verification, readers gain confidence in their environment, laying the groundwork for the practical exercises and programming challenges that lie ahead in the comprehensive "Programming With Java" curriculum. Configuring Visual Studio Code for Java Development In addition to traditional IDEs, many developers opt for Visual Studio Code due to its lightweight yet powerful features and extensive extensions. The section provides guidance on installing the necessary extensions for Java development in VS Code. // Installing Java Extension Pack in Visual Studio Code 1. Open VS Code
  • 22. 2. Navigate to Extensions (or use shortcut Ctrl+Shift+X) 3. Search for "Java Extension Pack" 4. Click "Install" to install the pack, which includes essential extensions for Java development. This extension pack includes features like language support, debugging tools, and Maven integration, enriching the VS Code environment for Java programming. Configuring Build Tools: Maven or Gradle For a more comprehensive Java development environment, the book addresses the configuration of build tools such as Maven or Gradle. These tools simplify project management, dependency resolution, and build processes. Here's an example of configuring Maven within VS Code: // Configuring Maven in Visual Studio Code 1. Install the "Maven for Java" extension. 2. Open a Java project with a `pom.xml` file. 3. VS Code will prompt to import the Maven project. Click "Import Changes." By incorporating these details, readers gain insights into configuring a diverse set of tools within Visual Studio Code, tailoring their environment to their preferred workflows. Running Java Programs in VS Code The section concludes by demonstrating how to run Java programs directly from Visual Studio Code. It guides readers on configuring run and debug configurations, ensuring a seamless experience when executing Java code within the VS Code environment. // Running Java Programs in Visual Studio Code 1. Open a Java file.
  • 23. 2. Right-click and select "Run" or "Debug" based on the desired configuration. By including VS Code in the discussion, the book acknowledges the diverse preferences within the Java development community, ensuring that readers can choose an environment that best suits their needs and workflow. This comprehensive approach prepares them for a holistic Java programming experience, whether using traditional IDEs or lightweight editors like Visual Studio Code. Writing Your First Java Program The pivotal moment of transitioning from theory to practical application unfolds in the "Writing Your First Java Program" section within the "Introduction to Java Programming" module of "Programming With Java." This section is designed to empower readers with the foundational skills needed to create and execute a simple Java program. It serves as a hands-on initiation into the syntax and structure of Java code, establishing a solid base for more complex programming tasks. Creating a Simple Java Class The journey begins by guiding readers through the process of creating a simple Java class. In Java, a class serves as the blueprint for objects, encapsulating data and behavior. The book introduces the essential components of a Java class, starting with the class declaration. // Java Class Declaration public class MyFirstProgram { // Class body goes here } By breaking down the syntax, readers grasp the significance of the public class declaration, laying the groundwork for a deeper understanding of Java's object-oriented nature. Adding the Main Method for Execution The heart of any Java program lies within the main method. This method acts as the entry point for the program, specifying the code to
  • 24. be executed when the program runs. The book elucidates the structure of the main method and its importance. // Main Method Declaration public class MyFirstProgram { public static void main(String[] args) { // Code to be executed goes here } } This snippet provides readers with a clear delineation of the main method, emphasizing the necessity of its signature for program execution. Printing "Hello, Java!" to the Console The section culminates in the execution of a quintessential "Hello, World!" program. By using the System.out.println statement, readers learn how to output text to the console, a fundamental aspect of Java programming. // Hello, World! Program public class MyFirstProgram { public static void main(String[] args) { System.out.println("Hello, Java!"); } } Through this illustrative example, readers witness the practical application of Java syntax, witnessing the tangible output of their first Java program. Compiling and Running the Java Program Completing the journey, the section walks readers through the compilation and execution process. It introduces the javac compiler for Java source code and the java command for running the compiled program. # Compile Java Program javac MyFirstProgram.java # Run Java Program java MyFirstProgram
  • 25. By including these steps, the book ensures that readers not only write Java code but also gain proficiency in the essential tasks of compiling and executing their programs. This section, therefore, serves as a pivotal stepping stone in the practical application of Java programming concepts within the broader framework of "Programming With Java." Understanding the Java Virtual Machine (JVM) Within the "Introduction to Java Programming" module of "Programming With Java," the section dedicated to "Understanding the Java Virtual Machine (JVM)" unveils the core mechanism that makes Java a platform-independent language. This section delves into the inner workings of the JVM, shedding light on how it interprets and executes Java bytecode, providing a crucial bridge between Java's source code and the underlying hardware. Overview of the JVM Architecture The journey begins with an exploration of the JVM architecture, elucidating its key components and their roles. Readers are introduced to the classloader, responsible for loading Java classes into memory, the bytecode verifier ensuring code integrity, the Just- In-Time (JIT) compiler optimizing performance, and the execution engine translating bytecode into machine code. This multifaceted architecture underpins Java's ability to run on diverse platforms without modification. // Sample Java Class public class SampleClass { public void printMessage() { System.out.println("This is a sample message."); } } By breaking down the Java class into its bytecode representation, readers gain insight into the intermediary stage that facilitates platform independence. Class Loading and Execution Flow
  • 26. The section navigates through the class-loading process, demystifying how the JVM locates, loads, and links classes during program execution. The book provides a comprehensive overview of the class initialization sequence and the role of the ClassLoader in dynamically loading classes into the Java runtime environment. // Class Loading in Java public class MyClass { public static void main(String[] args) { SampleClass sample = new SampleClass(); sample.printMessage(); } } By dissecting the execution flow, readers gain a profound understanding of how the JVM manages classes and their dependencies during runtime. Bytecode Verification and JIT Compilation To ensure the security and integrity of Java programs, the section delves into bytecode verification, an essential step in the class- loading process. Readers discover how the JVM meticulously examines bytecode for adherence to Java language specifications, preventing runtime errors and potential security vulnerabilities. The discussion extends to the JIT compilation process, where bytecode is translated into native machine code for enhanced performance. // JIT Compilation in Action public class PerformanceExample { public static void main(String[] args) { // Code triggering JIT compilation for (int i = 0; i < 1000; i++) { System.out.println("Executing code for JIT compilation."); } } } By illustrating the connection between code execution patterns and JIT compilation, readers gain insights into optimizing Java programs for runtime efficiency. Memory Management and Garbage Collection
  • 27. Concluding the section, readers delve into memory management and garbage collection within the JVM. The book demystifies how the JVM handles memory allocation and automatic garbage collection, ensuring efficient resource utilization and preventing memory leaks. // Memory Management in Java public class MemoryExample { public static void main(String[] args) { // Code demonstrating memory allocation and usage int[] numbers = new int[1000]; // ... } } Through these examples, the section unravels the intricacies of the JVM's role in managing memory, providing readers with a comprehensive understanding of the Java runtime environment. This foundational knowledge equips them to write efficient and reliable Java programs as they progress through the "Programming With Java" curriculum.
  • 28. Module 2: Variables and Data Types in Java In the dynamic world of programming, understanding the fundamentals of variables and data types is akin to mastering the alphabet before crafting intricate prose. The module "Variables and Data Types in Java" within the book "Programming With Java" is a foundational exploration that propels readers into the heart of Java programming. This module serves as a stepping stone for both novice and experienced programmers, laying the groundwork for robust and efficient code construction by unraveling the nuances of variables and data types in the Java language. The Significance of Variables in Java The module commences by demystifying the concept of variables, which are essential placeholders for storing and manipulating data in a program. Readers delve into the rules for naming variables, understanding their scope, and appreciating the dynamic nature of Java's variable declaration. Through practical examples and exercises, the module ensures that learners grasp the pivotal role variables play in shaping the flow and logic of a Java program. Understanding Data Types: The Building Blocks of Java Programs A pivotal aspect of programming proficiency lies in comprehending the diverse data types available in a language. This module meticulously explores Java's rich assortment of data types, ranging from primitive types like integers and floating-point numbers to more complex ones such as arrays and objects. The module elucidates the characteristics and use cases of each data type, guiding readers in making informed decisions when choosing the most suitable type for a given scenario. Declaration and Initialization: Navigating the Java Syntax
  • 29. Navigating through the intricacies of Java syntax, the module addresses the process of variable declaration and initialization. Readers learn the syntax for declaring variables with precision, ensuring that the type and name are specified appropriately. The module extends to the crucial task of initializing variables, elucidating how this process sets the initial value for a variable, a fundamental step in ensuring predictable program behavior. The Dynamic Nature of Variables in Java Java's dynamic nature shines through in its support for variables that can adapt to different data types during runtime. The module explores the concept of dynamic typing, showcasing how variables can be reassigned to different types, enhancing flexibility in programming. This dynamic nature allows Java developers to create versatile and adaptive code structures, responding dynamically to changing requirements. Building a Foundation for Advanced Concepts The "Variables and Data Types in Java" module serves as a cornerstone for mastering more advanced Java concepts. Armed with a profound understanding of variables and data types, readers are well-equipped to explore topics like control flow, methods, and object-oriented programming in subsequent modules. By providing a comprehensive foundation, this module ensures that learners are primed to leverage the full power of Java in crafting efficient, scalable, and maintainable software solutions. Declaring and Initializing Variables Within the comprehensive module on "Variables and Data Types in Java" in the book "Programming With Java," the section dedicated to "Declaring and Initializing Variables" serves as a crucial foundation for understanding the dynamic nature of variables in Java. This section delves into the nuances of variable declaration, exploring how Java developers define and set the stage for manipulating data within their programs. Understanding Variable Declaration in Java The section commences with a thorough exploration of variable declaration, a fundamental concept in Java programming. In Java,
  • 30. declaring a variable involves specifying its type and name. For instance: // Variable Declaration in Java int myNumber; double pi; String greeting; Here, readers are introduced to integer (int), floating-point (double), and string (String) variables. By breaking down the syntax, the section ensures that learners comprehend the essential components of variable declaration and gain familiarity with common data types. Variable Initialization: Setting Initial Values Moving beyond declaration, the section navigates into the realm of variable initialization. Initialization involves assigning an initial value to a variable, allowing it to hold meaningful data from the outset. For example: // Variable Initialization in Java int myNumber = 42; double pi = 3.14; String greeting = "Hello, Java!"; Through these examples, readers witness the synergy between declaration and initialization, recognizing how this dynamic duo forms the bedrock of variable usage in Java programs. Dynamic Typing: Adapting Variables at Runtime A distinctive feature of Java is its support for dynamic typing, enabling variables to adapt to different data types during runtime. The section explores scenarios where the same variable can take on different forms, fostering adaptability within a program. // Dynamic Typing in Java var dynamicVar = 42; // an integer dynamicVar = 3.14; // now a double dynamicVar = "Java"; // now a String Here, the use of the var keyword exemplifies dynamic typing, allowing the variable to seamlessly transition between integer, double, and string types.
  • 31. Scope and Lifetime of Variables The section delves into the concepts of scope and lifetime, elucidating how these factors influence a variable's accessibility and existence within a program. Understanding the scope and lifetime of variables is pivotal for writing efficient and error-free Java code. // Scope and Lifetime in Java public class VariableExample { public static void main(String[] args) { int localVar = 10; // Local variable with limited scope // ... } } By exploring code snippets like this, readers gain insights into how variables are confined to specific contexts and when they cease to exist, enhancing their ability to manage and optimize Java programs effectively. Conclusion and Building Blocks for Advanced Concepts The "Declaring and Initializing Variables" section serves as a pivotal building block within the broader module. By comprehending the intricacies of variable declaration, initialization, dynamic typing, and the nuances of scope and lifetime, readers are well-prepared to delve into more advanced Java concepts. This foundational knowledge equips learners with the skills necessary to craft sophisticated and resilient Java programs as they progress through the "Programming With Java" curriculum. Java's Primitive Data Types: int, float, boolean, etc. The cornerstone of effective Java programming lies in understanding and harnessing its diverse set of primitive data types. The section on "Java's Primitive Data Types" within the module "Variables and Data Types in Java" in "Programming With Java" delves into the intricacies of these fundamental building blocks. Through a detailed exploration of int, float, boolean, and other essential data types, this section equips learners with the foundational knowledge to handle a variety of data in their Java programs.
  • 32. Integers: The Foundation of Whole Numbers The section initiates with a close examination of the int data type, representing whole numbers without decimal points. In Java, the int data type is used for storing integer values within a specific range. // int Data Type in Java int myInteger = 42; By exploring the syntax and application of int, readers grasp the significance of this fundamental data type in representing whole numbers in Java programs. Floating-Point Numbers: Precision with float and double Moving beyond integers, the section navigates into the realm of floating-point numbers using the float and double data types. These types accommodate values with decimal points, offering varying levels of precision. // float and double Data Types in Java float myFloat = 3.14f; double myDouble = 3.1415926535; Through these examples, readers gain insight into the nuances of choosing between float and double based on the precision requirements of their Java applications. Boolean: True or False Values The discussion extends to the boolean data type, a binary type representing true or false values. Booleans are fundamental for decision-making in Java programs, often determining the flow of control within conditional statements. // boolean Data Type in Java boolean isJavaFun = true; By exploring boolean data types, readers understand their pivotal role in crafting conditional expressions and logical operations. Character: Representing Single Characters
  • 33. The section further explores the char data type, designed for storing individual characters. This data type is integral for handling letters, digits, and symbols in Java programs. // char Data Type in Java char myChar = 'A'; Through examples like these, learners gain a comprehensive understanding of the char data type and its application in handling individual characters. Byte and Short: Compact Integer Representations The module delves into the less commonly used but equally important byte and short data types, providing compact representations for integer values within specific ranges. // byte and short Data Types in Java byte myByte = 127; short myShort = 32000; By exploring these data types, readers recognize their utility in scenarios where memory conservation and efficiency are paramount. Conclusion: Foundational Knowledge for Data Handling The "Java's Primitive Data Types" section concludes by emphasizing the foundational role these data types play in Java programming. By comprehending the intricacies of int, float, boolean, char, byte, and short, readers are well-equipped to make informed decisions when selecting the appropriate data type for handling different kinds of data in their Java programs. This foundational knowledge sets the stage for more advanced explorations within the realm of "Programming With Java." Type Casting and Conversion in Java The intricacies of handling data in Java extend beyond the realm of primitive data types, leading to the necessity of understanding type casting and conversion. The "Type Casting and Conversion in Java" section within the "Variables and Data Types in Java" module of "Programming With Java" unravels the mechanisms by which
  • 34. developers can manipulate and transform data between different types. This section is instrumental in empowering learners to effectively manage data in diverse scenarios, ensuring flexibility and precision in their Java programs. Understanding Type Casting The journey begins with a deep dive into type casting, a process essential for converting data from one type to another. Java supports two types of casting: implicit (automatic) casting and explicit (manual) casting. // Implicit Casting in Java int intValue = 42; double doubleValue = intValue; // Automatic casting from int to double Here, the integer value is implicitly cast to a double without requiring explicit intervention. The section elucidates scenarios where implicit casting occurs seamlessly and how it impacts the precision and range of data. Explicit Casting: Precision and Caution The section transitions to explicit casting, where developers manually convert data from one type to another. Explicit casting is crucial when transforming data to a type with a smaller range or lower precision. // Explicit Casting in Java double doubleValue = 3.14; int intValue = (int) doubleValue; // Manual casting from double to int Through examples like these, readers understand the importance of explicit casting in scenarios where precision must be carefully managed to prevent data loss. Numeric Promotion: The Hierarchy of Types The section delves into the concept of numeric promotion, unveiling the hierarchy of data types in Java. When performing operations involving different numeric types, Java automatically promotes the smaller type to the larger type to maintain precision.
  • 35. // Numeric Promotion in Java int intValue = 10; double doubleValue = 3.5; double result = intValue * doubleValue; // Promotion of int to double for precision By exploring numeric promotion, readers gain insights into how Java ensures consistent and accurate results in arithmetic operations involving different numeric types. Conversion Between Data Types Expanding the discussion, the section explores conversion between data types beyond numeric types. It covers scenarios where data must be transformed between primitives and objects, emphasizing the principles of widening and narrowing conversions. // Conversion Between Data Types in Java int intValue = 42; String stringValue = Integer.toString(intValue); // Converting int to String Through examples like these, readers gain proficiency in converting data between different types, enabling seamless integration of diverse data in their Java programs. Conclusion: Precision, Flexibility, and Best Practices The "Type Casting and Conversion in Java" section concludes by emphasizing the significance of precision, flexibility, and adherence to best practices when dealing with type casting and conversion. This foundational knowledge equips learners with the tools to manipulate data effectively in Java, fostering adaptability and precision within their programming endeavors. Variable Scope and Lifetime in Java Navigating the intricate landscape of Java programming involves not only understanding data types and variable declaration but also grasping the concepts of variable scope and lifetime. The "Variable Scope and Lifetime in Java" section within the "Variables and Data Types in Java" module of "Programming With Java" delves into these crucial aspects, shedding light on how variables are accessed, where they exist, and when they cease to exist within a program.
  • 36. Understanding Variable Scope The journey begins by dissecting the notion of variable scope, which defines the region or context in which a variable can be accessed. In Java, variables can have local scope, method scope, class scope, or even global scope, each with its own set of rules and implications. // Local Variable with Method Scope in Java public class ScopeExample { public void myMethod() { int localVar = 42; // Local variable with method scope // ... } } By exploring the syntax and implications of local scope, readers gain insight into how variables are confined to specific methods, limiting their accessibility. Class Scope: Member Variables and Fields The section transitions to class scope, where variables become member variables or fields of a class. These variables exist throughout the class and are accessible by all methods within the class. // Class Scope with Member Variable in Java public class ScopeExample { private int classVar; // Class variable with class scope public void myMethod() { // Accessing classVar within the method int result = classVar * 10; // ... } } Here, the class variable classVar demonstrates class scope, allowing its use across various methods within the class. Global Scope: Constants and Beyond While Java doesn't have truly global variables, constants created using the final keyword often serve a similar purpose. The section
  • 37. explores the concept of constants and their implications for variable scope. // Constants with Global Scope in Java public class ConstantsExample { public static final double PI = 3.14; // Constant with global scope // ... } Through examples like these, readers understand how constants can achieve a form of global scope, providing consistent values across an entire Java program. Variable Lifetime: From Birth to Garbage Collection The section transitions to the concept of variable lifetime, elucidating when variables come into existence and when they are eventually removed from memory. Local variables have a limited lifespan, existing only within the scope of the method or block where they are declared. // Variable Lifetime in Java public class LifetimeExample { public void myMethod() { int localVar = 42; // Local variable with limited lifetime // ... } } By exploring these examples, readers comprehend how variable lifetime is intimately tied to their scope, influencing memory management in Java programs. Conclusion: Balancing Accessibility and Resource Management The "Variable Scope and Lifetime in Java" section concludes by emphasizing the delicate balance between variable accessibility and resource management. By mastering the nuances of variable scope and lifetime, readers gain the expertise to optimize their Java programs for efficiency and reliability, ensuring that variables are utilized precisely where needed and released when their purpose is served. This foundational knowledge paves the way for constructing
  • 38. robust and scalable Java applications within the broader context of "Programming With Java."
  • 39. Module 3: Basic Input and Output in Java In the expansive domain of Java programming, the module "Basic Input and Output in Java" within the book "Programming With Java" stands as a foundational exploration. This module serves as a vital entry point, guiding learners through the essential facets of handling input and output in Java applications. Mastering these fundamental skills is paramount for creating programs that are not only dynamic and interactive but also capable of processing data from external sources and generating meaningful output. As we embark on this journey, we will unravel the intricacies of input and output mechanisms, equipping readers with the tools necessary for user interaction and practical software development. Foundations of Input Handling in Java Our exploration begins by unveiling the foundations of input handling in Java. We will delve into the methods through which programs can receive data, whether from users or external sources. The use of tools like the Scanner class will be demystified, showcasing its versatility in capturing user input. These discussions will form the groundwork for constructing applications that actively engage with users, responding dynamically to their input. Effective Output Presentation in Java Transitioning seamlessly, the module explores the art of output in Java, emphasizing strategies for presenting information effectively. Techniques such as System.out.println will be highlighted, enabling learners to convey results, messages, or relevant information to the console or other output streams. Through practical examples, readers will grasp the syntax and
  • 40. applications of these output methods, understanding the power of clear and concise communication in the context of software development. File Input and Output Mastery Expanding the scope, our journey extends into the realm of file input and output – a pivotal skill for applications dealing with persistent data storage. Classes like FileReader, BufferedReader, FileWriter, and PrintWriter will be introduced, empowering readers with the ability to read from and write to files. This newfound proficiency opens doors to handling external data sources and enhancing the robustness of Java applications. Conclusion: Empowering Interactive and Dynamic Java Programs As the "Basic Input and Output in Java" module concludes, learners will possess a transformative set of skills. The ability to handle input effectively, present output dynamically, and manage external data sources empowers developers to create interactive, dynamic, and user-friendly Java applications. This foundational knowledge not only serves as a launching pad for further exploration within "Programming With Java" but also propels learners toward mastery in the realm of software development. Using System.out.println and System.out.print for Output The section on using System.out.println and System.out.print for output is foundational within the module "Basic Input and Output in Java" in the book "Programming With Java." This segment serves as an initiation into the world of displaying information to the console, a crucial skill for any Java programmer. The two primary methods, System.out.println and System.out.print, are instrumental in conveying output to the console window. The System.out.println method is employed to print text or variables to the console, followed by a newline character. This ensures that subsequent output appears on a new line, enhancing readability. Below is a simple example illustrating the use of System.out.println: public class PrintExample { public static void main(String[] args) { System.out.println("Hello, World!"); int number = 42; System.out.println("The value of the variable is: " + number);
  • 41. } } In this example, the text "Hello, World!" is printed to the console followed by the value of the variable number. The use of System.out.println ensures that each statement is displayed on a new line. On the other hand, the System.out.print method achieves a similar outcome but without appending a newline character. This means that consecutive System.out.print statements will appear on the same line. The following code snippet illustrates the use of System.out.print: public class PrintExample { public static void main(String[] args) { System.out.print("Hello, "); System.out.print("World!"); int number = 42; System.out.print(" The value of the variable is: " + number); } } In this example, the output will be "Hello, World! The value of the variable is: 42" all on the same line due to the use of System.out.print. Understanding when to use System.out.println for new lines and System.out.print for continuous output is crucial for crafting well- formatted and readable console outputs in Java. This section serves as a fundamental building block, setting the stage for learners to progress to more complex input and output operations as they delve deeper into the "Basic Input and Output in Java" module. Reading User Input with Scanner Class The section on reading user input with the Scanner class is a pivotal component of the module "Basic Input and Output in Java" in the book "Programming With Java." This segment introduces learners to the essential skill of obtaining input from the user, enabling interactive and dynamic Java programs. The Scanner class, part of the java.util package, facilitates the reading of various types of input from the console, providing a versatile tool for user interaction.
  • 42. import java.util.Scanner; public class UserInputExample { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.print("Enter your name: "); String name = scanner.nextLine(); System.out.println("Hello, " + name + "!"); System.out.print("Enter your age: "); int age = scanner.nextInt(); System.out.println("You are " + age + " years old."); scanner.close(); } } In this example, a Scanner object is created, initialized with System.in to read input from the console. The program prompts the user to enter their name and age, utilizes scanner.nextLine() to capture a full line of text for the name, and scanner.nextInt() to capture an integer for the age. The acquired input is then used to generate personalized output messages. The Scanner class provides various methods for reading different data types, including nextLine() for strings, nextInt() for integers, nextDouble() for doubles, and more. It allows developers to interactively gather user input, enhancing the adaptability and user- friendliness of Java applications. Understanding the use of Scanner for user input is foundational for creating applications that respond dynamically to user responses. However, it's important to note that improper usage, such as not closing the Scanner when done, can lead to resource leaks. Therefore, as illustrated in the example, it's good practice to close the Scanner using the close() method to release system resources associated with it. This section equips learners with the skills to make Java programs interactive, fostering user engagement and expanding the scope of applications. As learners progress through the "Basic Input and Output in Java" module, they build a strong foundation for creating
  • 43. versatile and user-centric Java programs within the broader context of "Programming With Java." Formatting Output with printf The section on formatting output with printf is a crucial aspect of the module "Basic Input and Output in Java" within the book "Programming With Java." This segment introduces learners to the powerful and flexible printf method, offering a sophisticated way to control the appearance of output in the console. Derived from the C programming language, printf allows for precise formatting, making it an essential tool for crafting well-structured and visually appealing output. public class PrintfExample { public static void main(String[] args) { String name = "John"; int age = 25; double salary = 50000.75; System.out.printf("Name: %s%n", name); System.out.printf("Age: %d%n", age); System.out.printf("Salary: $%.2f%n", salary); } } In this example, the printf method is utilized to format and print information. The format specifier %s is used for strings, %d for integers, and %f for floating-point numbers. The %n is a platform- independent newline character, ensuring proper line breaks in different operating systems. Additionally, .2 in %.2f specifies that the floating-point number should be displayed with two decimal places. Understanding the syntax and functionality of printf is fundamental for developers striving to create output that is both readable and visually consistent. The format specifiers within the format string act as placeholders, and the corresponding values are supplied after the string, ensuring a seamless connection between the format and the actual data. Developers can leverage a variety of format specifiers and modifiers with printf, such as controlling the width and precision of numeric values, specifying field alignment, and incorporating special
  • 44. characters. This versatility empowers developers to tailor the output according to specific requirements and enhances the overall aesthetic of the displayed information. The printf method not only offers enhanced formatting capabilities but also contributes to code maintainability by keeping the formatting details separate from the content. This separation allows developers to modify the appearance of output without altering the underlying logic, promoting clean and modular code. As learners progress through the "Basic Input and Output in Java" module, mastering the printf method provides a valuable skill set for creating professional-looking and well-organized console output in Java applications. It serves as a cornerstone for effective communication of information to users and ensures that the visual representation of data aligns with the overall quality of the code within the broader context of "Programming With Java." Debugging Techniques in Java The section on debugging techniques in Java is an indispensable component of the module "Basic Input and Output in Java" within the book "Programming With Java." Debugging is a critical skill for any developer, and this section introduces learners to various tools and methodologies to identify, isolate, and rectify errors within their Java code. Debugging is an iterative and problem-solving process, and mastering these techniques is essential for writing robust and error- free programs. public class DebuggingExample { public static void main(String[] args) { int[] numbers = {1, 2, 3, 4, 5}; int sum = 0; for (int i = 0; i <= numbers.length; i++) { sum += numbers[i]; } System.out.println("The sum is: " + sum); } }
  • 45. In this example, a common mistake is made by using <= instead of < in the loop condition. This error leads to an ArrayIndexOutOfBoundsException as the loop attempts to access an index beyond the array's bounds. Understanding how to identify and rectify such errors is a key aspect of effective debugging. Utilizing Breakpoints and Stepping Through Code Debugging often involves stepping through the code to understand its flow and identify where issues arise. Modern Integrated Development Environments (IDEs) provide tools for setting breakpoints, allowing developers to pause the program's execution at specific points and inspect variable values. By stepping through the code, learners can observe the state of variables and pinpoint the exact location of errors. public class DebuggingExample { public static void main(String[] args) { int[] numbers = {1, 2, 3, 4, 5}; int sum = 0; for (int i = 0; i < numbers.length; i++) { sum += numbers[i]; // Set a breakpoint here } System.out.println("The sum is: " + sum); } } Setting a breakpoint on the line with the sum calculation allows developers to observe the changing values of variables during each iteration of the loop. Leveraging Print Statements for Tracing Execution Another fundamental debugging technique involves strategically placing print statements in the code to trace its execution. This method is especially useful for identifying the flow of control and understanding how variables change at different points in the program. public class DebuggingExample { public static void main(String[] args) { int[] numbers = {1, 2, 3, 4, 5};
  • 46. int sum = 0; for (int i = 0; i < numbers.length; i++) { System.out.println("Adding " + numbers[i] + " to the sum."); sum += numbers[i]; } System.out.println("The sum is: " + sum); } } Print statements provide insight into the program's behavior, helping learners identify unexpected values or iterations that lead to errors. Exception Handling for Predictable Error Resolution Understanding and implementing exception handling is a crucial debugging technique. By catching and handling exceptions gracefully, developers can prevent runtime crashes and create more robust applications. This involves using constructs like try-catch blocks to manage potential errors. public class DebuggingExample { public static void main(String[] args) { int[] numbers = {1, 2, 3, 4, 5}; int sum = 0; try { for (int i = 0; i <= numbers.length; i++) { sum += numbers[i]; } } catch (ArrayIndexOutOfBoundsException e) { System.err.println("Array index out of bounds. Ensure proper loop condition."); } System.out.println("The sum is: " + sum); } } In this example, the try-catch block prevents the program from crashing due to the ArrayIndexOutOfBoundsException by handling it and providing a meaningful error message. Understanding and applying these debugging techniques equips learners with the tools necessary to identify and resolve issues within their Java programs. This skill is invaluable for developers striving to
  • 47. create reliable and efficient software within the broader context of "Programming With Java."
  • 48. Module 4: Operators and Expressions in Java Within the rich tapestry of Java programming, the module "Operators and Expressions in Java" stands as a pivotal exploration within the pages of the book "Programming With Java." This module serves as a fundamental guide, unraveling the intricate world of operators and expressions in the Java language. Operators are the building blocks of computation, and expressions define the language's capability to articulate logic and calculations. By delving into this module, readers embark on a journey to comprehend the nuances of how Java handles operations, manipulates data, and evaluates expressions – skills that are essential for constructing efficient and meaningful Java programs. Understanding Java Operators The journey begins with a comprehensive exploration of Java operators – symbols that represent computations, comparisons, and other operations. From arithmetic operators like addition and subtraction to logical operators such as AND and OR, the module dissects each category, elucidating their roles and applications within the Java language. Arithmetic Operators: Foundations of Calculation Arithmetic operators form the bedrock of numerical computations in Java. This section of the module delves into operators like +, -, *, /, and %, unraveling their functionality and showcasing how they manipulate numeric data. Through practical examples, learners gain insights into the precision and rules governing arithmetic operations in Java. Relational and Logical Operators: Crafting Conditions
  • 49. The module seamlessly transitions into relational and logical operators, exploring their significance in crafting conditional expressions. By dissecting operators like ==, !=, &&, and ||, readers gain proficiency in constructing logical conditions that dictate the flow of program execution. Practical scenarios illustrate the use of these operators in decision-making structures. Bitwise and Assignment Operators: Precision and Manipulation The exploration extends to bitwise and assignment operators, revealing their role in precision manipulation and variable assignment. This section guides learners through operators like &, |, ^, <<, >>, and =, showcasing how they operate at the bit level and facilitate efficient data manipulation. Understanding Java Expressions As the module progresses, attention shifts to expressions – combinations of operators and operands that produce a value. The intricacies of building meaningful expressions are unveiled, emphasizing how Java evaluates expressions and maintains data types during these evaluations. Compound and Conditional Expressions: Building Complexity This section of the module delves into compound and conditional expressions, where multiple operators collaborate to yield more complex results. By exploring expressions like a + b * c and x > 0 ? "Positive" : "Negative", learners gain proficiency in constructing intricate expressions that encapsulate varied logic within a single line of code. Conclusion: Empowering Code with Operators and Expressions As the "Operators and Expressions in Java" module concludes, readers emerge equipped with a profound understanding of the tools that form the backbone of Java computation. The ability to wield operators with precision and construct expressive expressions empowers developers to articulate intricate logic and build robust, efficient Java programs. This foundational knowledge not only sets the stage for more advanced topics within "Programming With Java" but also positions learners to tackle complex programming challenges with confidence and finesse.
  • 50. Arithmetic, Relational, and Logical Operators The section on arithmetic, relational, and logical operators is a fundamental exploration within the module "Operators and Expressions in Java" in the book "Programming With Java." These operators play a pivotal role in shaping the logic and functionality of Java programs, providing the means to perform calculations, make comparisons, and implement logical decisions. public class OperatorsExample { public static void main(String[] args) { // Arithmetic Operators int a = 10, b = 5; int sum = a + b; int difference = a - b; int product = a * b; int quotient = a / b; int remainder = a % b; // Relational Operators boolean isEqual = a == b; boolean isNotEqual = a != b; boolean isGreater = a > b; boolean isLessOrEqual = a <= b; // Logical Operators boolean logicalAnd = (a > 0) && (b > 0); boolean logicalOr = (a > 0) || (b > 0); boolean logicalNot = !(a > 0); // Displaying Results System.out.println("Arithmetic Operations:"); System.out.println("Sum: " + sum); System.out.println("Difference: " + difference); System.out.println("Product: " + product); System.out.println("Quotient: " + quotient); System.out.println("Remainder: " + remainder); System.out.println("nRelational Operations:"); System.out.println("Is Equal: " + isEqual); System.out.println("Is Not Equal: " + isNotEqual); System.out.println("Is Greater: " + isGreater); System.out.println("Is Less or Equal: " + isLessOrEqual); System.out.println("nLogical Operations:"); System.out.println("Logical AND: " + logicalAnd); System.out.println("Logical OR: " + logicalOr); System.out.println("Logical NOT: " + logicalNot); } }
  • 51. This example demonstrates the application of arithmetic operators (+, -, *, /, %), relational operators (==, !=, >, <=), and logical operators (&&, ||, !). These operators are fundamental for performing mathematical calculations, making decisions based on conditions, and creating logical flows within a program. Arithmetic Operators for Numeric Calculations Arithmetic operators are the building blocks for numeric calculations. The addition (+), subtraction (-), multiplication (*), division (/), and modulus (%) operators enable developers to perform various mathematical operations. These operators are crucial for tasks such as calculating totals, differences, products, and handling remainders. Relational Operators for Comparisons Relational operators facilitate comparisons between values. They include equality (==), inequality (!=), greater than (>), and less than or equal to (<=). These operators are vital for implementing decision- making processes based on the relationships between variables. Logical Operators for Decision Making Logical operators are essential for crafting conditional statements. The logical AND (&&), logical OR (||), and logical NOT (!) operators enable developers to create complex decision structures by combining and negating conditions. This flexibility is crucial for controlling program flow based on multiple criteria. Understanding and proficiently applying these operators is foundational for writing expressive and functional Java code. Whether performing numeric computations, making decisions based on conditions, or creating complex logical structures, these operators empower developers to craft efficient and logically sound programs. As learners progress through the "Operators and Expressions in Java" module, mastering these operators lays the groundwork for more sophisticated programming constructs within the broader context of "Programming With Java." Operator Precedence and Associativity
  • 52. The section on operator precedence and associativity is a critical exploration within the module "Operators and Expressions in Java" in the book "Programming With Java." These concepts define the order in which operators are evaluated within expressions, ensuring the correct interpretation of complex statements. Understanding operator precedence and associativity is fundamental for writing precise and unambiguous Java code. public class OperatorPrecedenceExample { public static void main(String[] args) { int a = 5, b = 3, c = 2; int result = a + b * c; int anotherResult = (a + b) * c; System.out.println("Result: " + result); System.out.println("Another Result: " + anotherResult); } } In this example, the expressions a + b * c and (a + b) * c illustrate the significance of operator precedence. The multiplication operator (*) takes precedence over the addition operator (+). Therefore, in the first expression, b * c is evaluated first, followed by the addition of a. In the second expression, the parentheses force the addition of a and b to be evaluated before the multiplication by c. Operator Precedence: Controlling the Order of Evaluation Operator precedence establishes the hierarchy of operations in an expression. It ensures that certain operations take precedence over others during evaluation. For example, multiplication and division typically have higher precedence than addition and subtraction. Developers need to be aware of this hierarchy to write expressions that produce the expected results. public class OperatorPrecedenceExample { public static void main(String[] args) { int x = 10, y = 5, z = 2; int result = x + y * z / 2; System.out.println("Result: " + result); } }
  • 53. In this example, the expression x + y * z / 2 is evaluated based on operator precedence. The multiplication and division operations are performed before the addition. Operator Associativity: Resolving Equal Precedence Operator associativity comes into play when operators of equal precedence appear in an expression. It determines the order in which operations are executed. For most operators in Java, associativity is left-to-right. This means that operations with the same precedence are executed from left to right. public class OperatorAssociativityExample { public static void main(String[] args) { int p = 8, q = 4, r = 2; int result = p / q / r; System.out.println("Result: " + result); } } In this example, the expression p / q / r is evaluated from left to right due to left-to-right associativity. The division operations are performed sequentially. Understanding and correctly applying operator precedence and associativity is crucial for writing expressions that yield the intended results. Developers must consider these principles when crafting complex statements to ensure the accuracy of calculations and the reliability of their Java code. As learners progress through the "Operators and Expressions in Java" module, mastering these concepts becomes integral to writing efficient and error-free code within the broader context of "Programming With Java." Using Operators for Expressions in Java The section on using operators for expressions in Java is a central topic within the module "Operators and Expressions in Java" in the book "Programming With Java." Operators are the building blocks of expressions, enabling developers to create dynamic and sophisticated computations. This section delves into the practical application of operators to construct meaningful expressions, emphasizing their role
  • 54. in mathematical calculations, logical evaluations, and variable manipulations. public class ExpressionsExample { public static void main(String[] args) { int a = 5, b = 3, c = 2; // Arithmetic Expressions int sum = a + b; int difference = a - b; int product = a * b; int quotient = a / b; int remainder = a % b; // Logical Expressions boolean isGreaterThan = a > b; boolean isEqualOrLess = a <= b; // Compound Expressions boolean complexCondition = (a > b) && (b < c); // Displaying Results System.out.println("Arithmetic Expressions:"); System.out.println("Sum: " + sum); System.out.println("Difference: " + difference); System.out.println("Product: " + product); System.out.println("Quotient: " + quotient); System.out.println("Remainder: " + remainder); System.out.println("nLogical Expressions:"); System.out.println("Is Greater Than: " + isGreaterThan); System.out.println("Is Equal or Less: " + isEqualOrLess); System.out.println("nCompound Expressions:"); System.out.println("Complex Condition Result: " + complexCondition); } } This example showcases the use of various operators in constructing expressions. Arithmetic expressions, utilizing operators such as +, -, *, /, and %, perform mathematical calculations. Logical expressions, with operators like >, <=, evaluate conditions and return boolean results. Compound expressions combine multiple conditions using logical operators (&& in this case) to create more intricate decision structures. Arithmetic Expressions: Performing Calculations
  • 55. Random documents with unrelated content Scribd suggests to you:
  • 56. whole and unchangeable, unswerving and unadaptable. Perfectly unadaptable. It is of such an one that I dream.” Imhof jumped up, and smoothed his coat. “Talk, talk!” he rattled, in the disagreeable military tone that he assumed in his moments of pseudo-virility. “Talk won’t improve things.” He passed his arm through Weikhardt’s, and as they left the terrace, which had been gradually filling with other guests, he recited, boldly, unashamed, and in the same tone, the alcaic stanza of Hölderlin: “Still man will take up arms against all who breathe; Compelled by pride and dread he consumes himself in conflict, and destroys the lovely Flower of his peace that is brief of blooming.” VII On their first evening in Hamburg, Crammon rented a box in the playhouse, and invited Christian, Johanna Schöntag, and Herr Livholm, one of the directors of the Lloyd, to be his guests. He had made the latter’s acquaintance in the hotel where he had gone to pay Eva a visit of welcome. He had liked the man, who cut a good figure, and so he had added him to the party in order, as he put it, to keep the atmosphere normal by the presence of an entirely neutral person. “Social skill,” he was accustomed to say, “is not unlike skill in cookery and serving. Between two heavy, rich dishes there must be one like foam that stimulates the palate quite superficially. Otherwise the meal has no style.” The play was a mediocre comedy, and Christian was frankly bored. Crammon thought it his duty to show a condescending and muffled amusement, and now and then he gave Christian a gentle poke, to persuade him also to show some appreciation of the performance.
  • 57. Johanna was the only one who was genuinely amused. The source of her amusement was an actor to whom a serious rôle had been assigned, but who talked with such silly affectation and false importance that every time he appeared she had to hold her lacy handkerchief to her lips to smother her laughter. Occasionally Christian gave the girl a far and estranged glance. She wasn’t either agreeable or the reverse; he did not know what to make of her. This feeling of his had not changed since he had first seen her during the journey in Eva’s company. She felt the coldness of his glance. Her merriment did not vanish; but on the lower part of her face appeared a scarcely perceptible shadow of disappointment. As though seeking for help, she turned to Christian. “The man is terribly funny, don’t you think so?” It was characteristic of her to end a question with a negative interrogation. “He’s certainly worth seeing,” Christian agreed politely. The door of the box opened, and Voss entered. He was faultlessly dressed for the occasion; but no one had expected or invited him. They looked at him in astonishment. He bowed calmly and without embarrassment, stood quite still, and gave his attention to the stage. Crammon looked at Christian. The latter shrugged his shoulders. After a while Crammon arose, and with sarcastic courtesy pointed to his seat. Voss shook his head in friendly refusal, but immediately thereafter assumed once more his air of humility and abjectness. He stammered: “I was in the stalls and looked up. I thought there was no harm in paying a visit.” Suddenly Crammon went out, and was heard quarrelling with the usher. Johanna had become serious, and looked down at the audience. Christian, as though to ward off disagreeable things, ducked his shoulders a little. The people in the near-by seats became indignant at the noise Crammon was making. Herr Livholm felt that the proper atmosphere had hardly been preserved. Amadeus Voss alone showed himself insensitive to the situation.
  • 58. He stood behind Johanna, and thought: “The hair of this woman has a fragrance that turns one dizzy.” At the end of the act he withdrew, and did not return. Late at night, when he had him alone, Crammon vented his rage on Christian. “I’ll shoot him down like a mad dog, if he tries that sort of thing again! What does the fellow think? I’m not accustomed to such manners. Damned gallow’s bird—where’d he grow up? Oh, my prophetic soul! I always distrusted people with spectacles. Why don’t you tell him to go to hell? In the course of my sinful life, I’ve come in contact with all kinds of people; I know the best and I know the dregs; but this fellow is a new type. Quite new, by God! I’ll have to take a bromide, or I won’t be able to sleep.” “I believe you are unjust, Bernard,” answered Christian, with lowered eyes. But his face was stern, reserved, and cold. VIII Amadeus Voss submitted the following plan to Christian: to go to Berlin, first as an unmatriculated student, and later to prepare himself for the state examination in medicine. Christian nodded approvingly, and added that he intended to go to Berlin shortly too. Voss walked up and down in the room. Then he asked brusquely: “What am I to live on? Am I to address envelopes? Or apply for stipends? If you intend to withdraw your friendship and assistance, say so frankly. I’ve learned to wade through the mud. The new kind won’t offer more resistance than the old.” Christian was thoroughly surprised. A week ago, in Holland, he had given Amadeus ten thousand francs. “How much will you need?” he asked. “Board, lodging, clothes, books....” Voss went over the items, and his expression was that of one who formulates demands and uses the tone of request only as a matter of courtesy. “I’ll be frugal.”
  • 59. “I shall order two thousand marks a month to be sent you,” Christian said, with an air of aversion. The impudent demand for money pained him. Possession weighed upon him like a mountain. He could not get his arms free nor lift his chest, and the weight grew heavier and heavier. In a bowl of chrysolite on the table lay a scarf-pin with one large, black pearl. Voss, whose hands always groped for some occupation, had taken it up, and held it between his thumb and index finger against the light. “Do you want the pin?” Christian asked. “Take it,” he persuaded Amadeus, who was hesitating. “I really don’t care about it.” Voss approached the mirror, and with a curious smile stuck the pin into his cravat. When Christian was left alone, he stood for a while quite lost in thought. Then he sat down, and wrote to his manager at Christian’s Rest. He wrote in his lanky script and his no less awkward style. “My dear Herr Borkowski:—I have determined to sell Christian’s Rest, together with all furnishings and objects of art, as well as the park, woods, and farms. I herewith commission you to find a capable and honest real estate dealer, who might telegraph me any favourable offers. You know people of that sort, and need merely drive over to Frankfort. Have the kindness to settle the matter as quietly as possible. No advertisements are to appear in the press.” Then he wrote a second letter to the manager of his racing stable at Waldleiningen. To write this he had to do more violence to his heart than the first had cost him, for he saw constantly fixed upon him the gentle or spirited eyes of the noble animals. He wrote: “My dear Herr Schaller:—I have determined to discontinue my racing stable. The horses are to be sold at auction or quietly to fanciers. I should prefer the latter method, and I suppose you share that feeling. Baron Deidinger of Deidingshausen was at one time much interested in Columbus and the mare Lovely. Inquire of him whether he wants them. Admirable and Bride o’ the Wind could be offered either to Prince Pless or Herr von Strathmann. Have my friend Denis Lay’s
  • 60. Excelsior sent to Baden-Baden, and boarded temporarily in the stables of Count Treuberg. I don’t wish him to remain at Waldleiningen alone.” When he had sealed the letters, he sighed with relief. He rang, and gave the letters to his valet. The latter had turned to go, when Christian called him back. “I’m very sorry to have to give you notice, Wilhelm,” he said. “I’m going to attend to myself hereafter.” The man could not trust his ears. He had been with Christian for three years, and was genuinely devoted to him. “I’m sorry, but it’s necessary,” said Christian, looked past the man, and had almost the same strange smile with which he had watched Amadeus Voss at the mirror putting the black pearl pin into his cravat. IX Crammon asserted that Amadeus Voss was paying his attentions to Johanna Schöntag. Johanna was annoyed, and tapped him with her long gloves. “I congratulate you on your conquest, Rumpelstilzkin,” Crammon teased her. “To have a monster like that in leash is no small achievement. I should advise muzzling the monster, however. What do you think, Christian, wouldn’t you advise a muzzle, too?” “A muzzle?” answered Christian. “Yes, if it would keep people from talking. So many talk too much.” Crammon bit his lips. The reproof struck him as harsh. Somewhere beneath the downs of life on which he lay and enjoyed himself, there was, evidently, a stone. The stone hurt. He sought for it, but the softness of the down calmed him again, and he forgot his pain. “I was sitting in the breakfast room, and waiting for Madame Sorel,” Johanna began in a voice whose every shading and inflection sought to woo Christian’s ear, “when Herr Voss came in and marched
  • 61. straight up to me. ‘What does that bad man want of me?’ I asked myself. He asked me, as though we’d been bosom friends for years, whether I didn’t want to go with him to St. Paul’s to hear the famous itinerant preacher Jacobsen. I couldn’t help laughing, and he stalked away insulted. But this afternoon, as I was leaving the hotel, he seemed suddenly to spring from the earth, and invited me to a trip around the harbour. He had rented a motor launch, and was looking for a companion. He had the same gruff familiarity, and when he left he was quite as insulted as before. And you call that paying attentions? I felt much more as though he were going to drag me off and murder me. But perhaps that’s only his manner.” She laughed. “You’re the only person, at all events, whom he distinguishes by observing at all,” Crammon said, with the same mockery. “Or the only one whom he considers his equal,” Johanna said, with a childlike frown. Christian was wondering: “Why does she laugh so often? Why are her hands so pudgy and so very pink?” Johanna felt his disapproval, and was as though paralysed. And yet Christian felt himself drawn toward her by some hidden power. Why should he resist? Why be so ceremonious? Such was his thought, as Johanna arose, and he, with unobtrusive glances, observed her graceful form that still possessed the flexibility of immaturity. He saw the nape of her slender neck, in which were expressed both the weakness of her will and the fineness of her temper. He knew these signs; he had often been guided by them and used them. Crammon, massive and magnificent in a great easy chair, spoke with some emphasis of Eva’s appearance on the morrow. The whole city was in a state of expectancy. But Christian and Johanna had suddenly become truly aware of one another. “Are you coming along?” Christian turned carelessly, and with a sense of boredom, to Crammon.
  • 62. “Yes, my boy, let us eat!” Crammon cried. He called Hamburg the Paradise of Saint Bernard, concerning whom, as his patron saint and namesake, he had instituted especial investigations, and who, according to him, had been a mighty trencherman during his lifetime at Tours. A frightened, subtle, and very feminine smile hovered about Johanna’s lips. As she preceded the two men, the motions of her dainty body expressed a vague oppression of the spirit, and at the same time a humorous rebellion against her own unfreedom. X Amadeus Voss knew that he had no one’s sympathy, no one’s except Christian’s. And him he suspected, watching him, weighing and analysing his words and actions. In his terror of hypocrisy and treachery, he practised both himself. Nothing healed or convinced or reconciled him. Least of all did he pardon Christian the fact that the latter’s glance and presence had the effect of subduing him. His bitterness moaned from his very dreams. He read in the Scriptures: “There was a certain house-holder, which planted a vineyard, and hedged it round about, and digged a winepress in it, and built a tower, and let it out to husbandmen, and went into a far country: and when the time of the fruit drew near, he sent his servants to the husbandmen that they might receive the fruits of it. And the husbandmen took his servants, and beat one, and killed another, and stoned another. Again he sent other servants, more than the first, and they did unto them likewise. But last of all, he sent unto them his son, saying, They will reverence my son. But when the husbandmen saw the son, they said among themselves, This is the heir; come, let us kill him, and let us seize on his inheritance. And they caught him, and cast him out of the vineyard, and slew him.”
  • 63. Sometimes he would not leave Christian’s side for hours. He would study his gestures and the expressions of his countenance, and all these perceptions fed the corrosive fire in his brain. For this was the heir! Then he would flee and bruise and stamp upon his very soul, until his consciousness of guilt cast him down into the very dust. He would return, and his demeanour would be a silent confession: “I can thrive only in your presence.” It seemed to him that this silence of his was like a cry; but it was not heard, and so his brother seemed again to become his foe. Thus he kept passing from darkness, through fires and fumes, back into the darkness. He suffered from his own embarrassment and importunateness. In the midst of luxury and plenty, into which he had been transferred by a fabulous turn of fortune, he suffered from the memories of his former poverty, still felt how it had bound and throttled him, and still rebelled against what was gone. He could not freely take what was given him, but closed his eyes, and shuddered with both desire and a pang of conscience. He would not look upon the pattern of his web of life. He turned its texture around, and brooded over the significance of the intricately knotted threads. And there was no human relationship which did not rouse his suspicion, no harmless conversation in which he did not seek a sting directed toward himself, no face that did not feed his hatred, no beauty whose counter part of ugliness he did not see. To him everything turned to poison and decay, all blossoms became noxious weeds, all velvet a Nessus shirt, all light an evil smouldering, every stimulus a wound: on every wall he saw the flaming letters, mene tekel upharsim. He could not yield himself or conquer the stubbornness of his heart. With the object of his desire in his very hands, his envy burned on. Whatever had once humiliated him spurred his vengefulness through retrospection. Chastisements which his father had inflicted distorted the old man’s image beyond the grave; his fellow pupils in the seminary had once strewn pepper into his coffee, and he could not forget it; he could not forget the expression on the face of Adeline Ribbeck with which she had given him his first month’s salary in a closed envelope; he remembered the contempt and contumely of
  • 64. hundreds, who had inflicted upon him their revenge for the oppression or degradation which they themselves had endured. He could not conquer these things nor forgive fate. The marks that had been burned into his flesh throbbed like new wounds. But at other times he would cast himself into the dust in prayer and in great need of forgiveness. Religious scruples plagued him into remorse; he panted for an hour’s release from consciousness, judged himself with cruel severity, and condemned himself to ascetic practices. And these hurled him into the other extreme of a wild, undiscriminating, and senseless dissipation and a mad waste of money. He could no longer resist the excitement of gambling, and fell into the hands of sharpers, drifted into loathsome dives, where he acted the part of a wealthy man and an aristocrat in incognito, for he desired to test this human mask and prove its worthlessness to himself. Since his companions took him seriously in this rôle, which filled his own mind with shame and despair, he took his high losses with apparent calm, and overlooked the open cheating. One evening the den in which he happened to be was raided by the police, and he escaped by a hair’s breadth. One creature clung to him, frightened him with possible dangers ahead, threatened exposure, and wrung from him a considerable sum of hush money. He became the prey of cocottes. He bought them jewels and frocks and instituted nightly revels. In his eyes they were outcasts that he used as a famishing man might slake his thirst at a mud puddle with no clean water within reach. And he was brutally frank with them. He paid them to endure his contempt. They were surprised, resisted only his most infamous abuses, and laughed at his unconquerable traits of the churchly hypocrite. Once he remained alone with a girl who was young and pretty. He had blindfolded himself. But suddenly he fled as though the furies were at his heels. Thrice he had set the date for his departure and as many times had put it off. The image of Johanna had joined that of Eva in his soul, and both raged in his brain. Both belonged to an unattainable world.
  • 65. Yet Johanna seemed less alien; she might conceivably hear his plea. Eva and her beauty were like a strident jeer at all he was. He had heard so much and read so much of her art that he determined to await her appearance, in order (as he told Christian) to form a judgment of his own, and be no longer at the mercy of those who fed her on mere adulation and brazen flattery. The audience was in full evening dress. Amadeus sat next to Christian in the magnificent and radiant hall, in which had gathered royal and princely persons, the senators of the free city, the heads of the official and financial world, and representatives of every valley and city of Germany. Christian had bought seats near the stage. Crammon, who was an expert in matters of artistic perspective, had preferred the first row in the balcony. With him were Johanna and Botho von Thüngen, to whom he had emphatically explained that the play of the dancer’s feet and legs was interfered with by the dark line of the stage below, while from their present position its full harmony would be visible. Amadeus Voss had almost determined to remain rigid in mind. He hardly resisted actively, for he did not expect anything powerful enough to make resistance worth while. He was cold, dull, unseeing. Suddenly there floated upon the stage a bird-like vision, a being miraculously eased of human heaviness, one who was all rhythm, and turned the rhythm of motion into music. She broke the chains of the soul, and made every emotion an image, every action a myth, every step a conquest over space and matter. But the face of Amadeus seemed to say: How can that serve me? How does that serve you? Filled by the fury of sex, he saw only a scabrous exhibition, and when the thunder of applause burst out, he showed his teeth. Eva’s last number was a little dramatic episode, a charming jeu d’esprit, which she had invented and worked out, to be accompanied by a composition of Delibes. It was very simple. She was Pierrot playing with a top. She regulated and guided the whimsical course of the toy. In ever new positions, turns, and rhythms, she finally drove
  • 66. the top toward a hole into which it disappeared. But this trivial action was so filled with life by the wealth and variety of her rhythmic gestures, so radiant with spirit and swiftest grace, so fresh in inspiration, so heightened in the perfection of its art, that the audience watched breathlessly, and released its own tensity in a fury of applause. In the foyer Crammon rushed up to Christian, and drew him through the crowd along the dim passage way that led back of the stage. Amadeus Voss, unnoticed by Crammon, followed them unthinkingly and morosely. The sight of the wings, of cliffs and trees, of discarded drops, electrical apparatus and pulleys and of the hurrying stage- hands, stirred in him a dull and hostile curiosity. An excited crowd thronged toward Eva’s dressing-room. She sat in the silken Pierrot costume of black and white, the dainty silver whip still in her hand, amid a forest of flowers. Before her kneeled Johanna Schöntag with an adoring moisture in her eyes. Susan gave her mistress a glass of cool champagne. Then in a mixture of five or six languages she tried to make it clear to the unbidden guests that they were in the way. But each wanted a look, a word, a smile of Eva for himself. Next to the room in which Eva sat, and separated from it by a thin partition with an open door, was a second dressing-room, which contained only her costumes and a tall mirror. Accidentally pushed in that direction, and not through any will of his own, Amadeus Voss suddenly found himself alone in this little chamber. Having entered it, his courage grew, and he ventured a little farther in. He looked around and stared at the garments that lay and hung here—the shimmering silks, the red, green, blue, white, and yellow shawls and veils, the fragrant webs of gauze, batiste, and tulle. There were wholly transparent textures and the heaviest brocades. One frock glowed like pure gold, another gleamed like silver; one seemed made of rose-leaves, another knitted of spun glass, one of white foam and one of amethyst. And there stood dainty shoes—a long row of them, shoes of Morocco leather and of kid and silk; and
  • 67. there were hose of all colours, and laces and ribands and antique beads and brooches. The air was drenched with a fragrance that stung his senses—a fragrance of precious creams and unguents, of a woman’s skin and hair. His pulses throbbed and his face turned grey. Involuntarily he stretched out his hand, and grasped a painted Spanish shawl. Angrily, greedily, beside himself, he crushed it in his hands, and buried his mouth and nose in it and trembled in every limb. At that moment Susan Rappard saw him, and pointed to him with a gesture of astonishment. Eva saw him too, gently thrust Johanna aside, arose, and approached the threshold. When she saw the man in his strange and absorbed ecstasy, she felt as though she had been spattered with filth, and uttered a soft, brief cry. Amadeus Voss twitched and dropped the shawl. His eyes were wild and guilty. With a light laugh and an expression of transcendent contempt, which summed up a long dislike, Eva raised the little silver whip and struck him full in the face. His features grew very white, in a contortion of voluptuousness and terror. In the tense silence Christian went up to Eva, took the silver whip from her hand, and said in a tone scarcely distinguishable from his habitual one: “Oh, no, Eva, I shall not let you do that.” He held the handle of the whip firmly at both ends, and bent it until the fragile metal snapped. Then he threw the two pieces on the floor. They gazed at each other. Disgust at Amadeus still flamed in Eva’s face. It yielded to her astonishment at Christian’s temerity. But Christian thought: “How beautiful she is!” And he loved her. He loved her in her black and white Pierrot’s costume with the black velvet buttons, he loved her with that little cap and its impudent little tassel on her head; he loved her, and she seemed incomparable to him, and his blood cried out after her as in those nights from which she had driven him forth. But he also asked himself: “Why has she grown evil?” And a strange compassion for her stole over him, and a stranger sense of liberation. And he smiled. But to all who were watching, this smile of his seemed a little empty.
  • 68. Again Amadeus Voss read in the Scripture: “What mean ye that ye beat my people to pieces, and grind the faces of the poor? Because the daughters of Zion are haughty, and walk with stretched forth necks and wanton eyes, walking and mincing as they go, and making a tinkling with their feet: Therefore the Lord will strike with a scab the crown of the head of the daughters of Zion, and the Lord will discover their secret parts. In that day will the Lord take away the bravery of their tinkling ornaments about their feet, and their cauls, and their round tires like the moon, the chains, and the bracelets, and the mufflers, the bonnets, and the ornaments of the legs, and the headbands, and the tablets, and the earrings, the rings, and nose jewels, the changeable suits of apparel, and the mantles, and the wimples, and the crisping pins, the glasses, and the fine linen, and the hoods and the veils. And it shall come to pass, that instead of sweet smell there shall be stink; and instead of a girdle a rent; and instead of well set hair baldness; and instead of a stomacher a girding of sack-cloth; and burning instead of beauty. Thy men shall fall by the sword, and thy mighty in the war. And her gates shall lament and mourn; and she being desolate shall sit upon the ground.” On the same evening he left for Berlin. XI Lorm and Judith had a magnificent apartment near the Tiergarten in Berlin. Edgar Lorm flourished. Order and regularity ruled his life. With childlike boastfulness he spoke of his home. His manager and friend, Dr. Emanuel Herbst, congratulated him on his visible rejuvenation. He introduced to Judith the people whom he had long valued; but she judged most of them sharply and without sympathy. Her characteristic arrogance drove away many who meant well. But under the sway of his new comforts Lorm submitted to her opinions.
  • 69. But he would not give up Emanuel Herbst. When Judith mocked at his waddling gait, his homeliness, his piping voice, his tactless jokes, Lorm grew serious. “I’ve known him for over twenty years. The things that annoy you endear him to me quite as much as those precious qualities in him which I know well, and which you’ve had no chance to discover.” “No doubt he’s a monster of virtue,” Judith replied, “but he bores me to extinction.” Lorm said: “One should get used to the idea that other people don’t exist exclusively for our pleasure. Your point of view is too narrowly that of use and luxury. There are human qualities that I value more highly than a handsome face or polished manners. One of these is trustworthiness. People with whom one has professional dealings often refuse to honour the demands of common decency—especially in regard to the keeping of their given word—with a calm frivolity that makes one’s gorge rise. So I’m intensely grateful to Herbst, since it means so infinitely much to me, for this—that our relations have never been shadowed by distrust, and that our simplest verbal agreements are as firm and as valid as a written contract.” Judith recognized that in this case she would have to change her tactics. She was amiable, as though she were convinced of his virtues, and sought to gain his favour. Dr. Herbst saw through her, but showed no consciousness of his insight. He treated her with an elaborate courtesy that seemed a trifle old-fashioned, and effectually concealed his reservations. Sometimes in the evening she would sit with the two men, and join in their shop talk of playwrights and plays, actors and actresses, successes and failures. And while she seemed attentive, and even asked an occasional question, she thought of her dressmaker, of her cook, of her weekly account, or of her old life, that was so different and had perished so utterly. And her eyes would grow hard. It would happen that she would pass through the rooms with a bitter expression on her face and a hostile glance for the things
  • 70. about her. She hated the many mirrors which Lorm required, the rugs that had been recently bought, the pretentious furniture and paintings, the countless bibelots, photographs, ornaments, books, and piously guarded souvenirs. She had never before lived in a house where other tenants above and below reminded her of their repulsive and unfamiliar lives. She listened to the slightest noises, and felt that she had fallen into a slum. It was hardly in harmony with her nature to wait each morning until her husband happened to rise, to see that the breakfast was complete, to stand aside while the barber, the masseur, the chauffeur, the messenger of the theatre, and the secretary had completed their tasks or received their instructions; to wait again until he returned from rehearsal, tired, annoyed, and hungry, and then to watch him at luncheon—a meal that he required to be both rich and exquisite—gobble his food; to guard him from noise and interruption when he memorized his lines; to answer strange voices on the telephone, to give information, refuse invitations, to send the troublesome away and to soothe the impatient. She was wholly out of her natural element, but she forced herself to endure even as she had endured bodily pain when the long needle had been thrust through her arm. Emanuel Herbst, who was a keen observer and a learned student of human nature, quietly analysed the relations of this husband and this wife. He said to himself: “Lorm is not fulfilling her expectations; so much is clear. She fancied she could peel him the way one peels an onion, and that the removal of each layer would reveal something so new and surprising as to make up to her for all she has renounced. She will soon discover her miscalculation, for Lorm is always the same. He can’t be stripped. He wears his costumes and puts on make-up. She will soon reproach him for this very ability to fill empty forms with a beautiful content, and to remain, in his own person, but a humble servitor of his art. And the more guilty he becomes in her eyes, the more power over him will she gain. For he
  • 71. is tired—tired to death of the affected, the flatterers and sentimentalists, of the sweets and easements of his daily life. Terribly spoiled as he is, he yearns unconsciously for chains and a keeper.” The result of his reflection filled Emanuel Herbst with anxious apprehension. But Judith remembered her dream—how she had lain beside a fish because it pleased her, and then beaten it in sudden rage over its cool, moist, slippery, opalescent scales. And she lay beside the fish and struck it, and the fish became more and more subservient and her own. Her constant terror was this thought: “I am poor, impoverished, dependent, without security.” The thought tormented her to such a degree that she once expressed it to the housekeeper. The latter was astonished and replied: “But in addition to your pin money, the master gives you two thousand marks a month for the house. Why should you yield to morbid fancies?” Judith looked at the woman suspiciously. She distrusted all whom she paid. The moment they mentioned money she fancied herself robbed. One day the cook gave notice. She was the fourth since the establishment of the household. A quantity of sugar was missing. There was a quarrel, an ugly one, and Judith was told things that no one had ever dared to tell her before. The secretary mislaid a key. When at last it was found Judith rushed to the drawer which it fitted to see whether the stationery, the pencils, and the pen-points were intact. The housekeeper had bought twenty yards of linen. Judith thought the price paid too high. She drove to the shop herself. The taxi-fare amounted to more than she could possibly have saved on the purchase. Then she chaffered with the clerk for a reduction, until it was granted her through sheer weariness. She told Lorm the story with a triumphant air. He neglected to praise her. She jumped up
  • 72. from the table, locked herself in her room, and went to bed. Whenever she thought that she had some reason for anger, she went to bed. Lorm came to her door, knocked softly, and asked her to open it. She let him stand long enough to regret his conduct, and then opened the door. She told her story all over, and he listened with a charming curiosity on his face. “You’re a jewel,” he said, and stroked her cheek and hand. But it would also happen, if she really wanted something, that she would spend sums out of all proportion to her wretched little economies. She would see a hat, a frock, an ornament in a show window, and not be able to tear herself away. Then she would go into the shop, and pay the price asked at once. One day she visited an auction sale, and happened to come in just as an old Viennese bon-bon dish was offered for sale. It was one of those objects that make little show, but which delight the collector’s heart. At first the dish didn’t tempt her at all. Then the high bidding for it excited her, and she herself began to bid for it. It kindled something in her, and she made bid after bid, and drove all competitors from the field. Hot and excited, she came home and rushed into Lorm’s study. Emanuel Herbst was with him. The two men sat by the fire in familiar talk. Judith disregarded Herbst. She stood before her husband, unwrapped the dish, and said: “Look at this exquisite thing I bought, Edgar.” It was toward evening, but no lights had been lit. Lorm loved the twilight and the flicker of the fire in his chimney, which was, alas, only a metropolitan imitation of a log fire. In the rich, red, wavering reflection of the glow, Judith looked charming in her delight and mobility. Lorm took the dish, regarded it with polite interest, drew up his lips a little, and said: “It’s pretty.” Herbst’s face puckered into innumerable ironical little wrinkles.
  • 73. Judith grew angry. “Pretty? Don’t you see that it’s magical, a perfect little dream, the sweetest and rarest thing imaginable? The connoisseurs were wild after it! Do you know what it cost? Eighteen hundred marks. And I had six or seven rabid competitors bidding against me. Pretty!” She gave a hard little laugh. “Give it to me. You handle it too clumsily.” “Calm yourself, sweetheart,” said Lorm gently. “I suppose its virtues are subtle.” But Judith was hurt, more by Herbst’s silent mockery than by Lorm’s lack of appreciation. She threw back her head, rustled through the room, and slammed the door behind her. When she was angry, her own manners had, at times, a touch of commonness. For a while the two men were silent. Then Lorm, embarrassed and with a deprecating smile, said: “A little dream ... for eighteen hundred marks.... Oh, well! There’s something childlike about her.” Emanuel Herbst rubbed his tongue up and down between his teeth and his upper lip. It made him look like an ancient baby. Then he ventured: “You ought to make it clear to her that eighteen hundred marks are one thousand eight hundred times one mark.” “She won’t get that far,” answered Lorm. “Somebody who has always lived on the open sea, and is suddenly transported to a little inland lake, finds it hard to get the new measurements and perspectives. But women are queer creatures.” He sighed and smiled. “Have a nip of whiskey, old man?” Sorrowfully Herbst rocked his Cæsarean head. “Why queer? They are as they are, and one must treat them accordingly. Only one mustn’t be under any mistaken impression as to what one has. For instance: A horseshoe is not birch wood. It looks like a bow, but you can’t bend it—not with all your might. If you string it, the string droops slackly and will never propel your arrow. All right, let’s have your whiskey.” “But occasionally,” Lorm replied cheerfully, and filled the tiny glasses, “you can turn a horseshoe into the finest Damascene steel.”
  • 74. “Bravo! A good retort! You’re as ready as Cardinal Richelieu. Your health!” “If you’ll let me be Richelieu, I’ll appoint you to be my Father Joseph. A great rôle, by the way. Your health, old man!” XII Crammon and Johanna Schöntag planned to drive to Stellingen to see Hagenbeck’s famous zoological gardens, and Crammon begged Christian to lend them his car. They were just about to start when Christian issued from the hotel. “Why don’t you come along?” Crammon asked. “Have you anything better to do? The three of us can have a very amusing time.” Christian was about to refuse, when he caught Johanna’s urgent and beseeching look. She had the art of putting her wishes into her eyes in such a way that one was drawn by them and lost the power to resist. So he said: “Very well, I’ll come along,” and took the seat next to Johanna’s. But he was silent on the whole drive. It was a sunny day of October. They wandered through the park, and Johanna made droll comments on the animals. She stopped in front of a seal, and exclaimed: “He looks quite like Herr Livholm, don’t you think so?” She talked to a bear as though he were a simple sort of man, and fed him bits of sugar. She said that the camels were incredible, and only pretended to look that way to live up to the descriptions in the books of natural history. “They’re almost as ugly as I am,” she added; and then, with a crooked smile: “Only more useful. At least I was told at school that their stomachs are reservoirs of water. Isn’t the world a queer place?” Christian wondered why she spoke so contemptuously of herself. She bent over a stone balustrade, and the sight of her neck
  • 75. somehow touched him. She seemed to him a vessel of poor and hurt things. Crammon discoursed. “It is very curious about animals. Scientists declare they have a great deal of instinct. But what is instinct? I’ve usually found them to be of an unlimited stupidity. On the estate where I passed my childhood, we had a horse, a fat, timid, gentle horse. It had but one vice: it was very ticklish. I and my playmates were strictly enjoined from tickling it. Naturally we were constantly tempted to tickle it. There were five of us little fellows—no higher than table legs. Each procured a little felt hat with a cock’s feather in it. And as the horse stood dull-eyed in front of the stable, we marched in single file under the belly of the stupid beast, tickling it with our feathers as we passed. The feathers tickled so frightfully that he kicked with all fours like a mule. It’s a riddle to me to this day how one of us, at least, failed to be killed. But it was amusing and grotesque, and there was no sign of instinct anywhere.” They went to the monkey house. A crowd stood about a little platform, on which a dainty little monkey was showing off its tricks under the guidance of a trainer. “I have a horror of monkeys,” said Crammon. “They annoy me through memory. Science bids me feel a relationship with them; but after all one has one’s pride. No, I don’t acknowledge this devilish atavism.” He turned around, and left the building in order to wait outside. Alone with Christian, a wave of courage conquered Johanna’s timidity. She took Christian’s arm and drew him nearer to the platform. She was utterly charmed, and her delight was childlike. “How dear, how sweet, how humble!” she cried. A spiritual warmth came from her to Christian. He yielded himself to it, for he needed it. Her boyish voice, however, stirred his senses and aroused his fear. She stood very close by him; he felt her quiver, the response to the hidden erotic power that was in him, and the other voices of his soul were silenced. He took her hand into his. She did not struggle, but a painful tension showed in her face.
  • 76. Suddenly the little monkey stopped in its droll performance and turned its lightless little eyes in terror toward the spectators. Some shy perception had frightened it; it seemed, somehow, to think and to recollect itself. As it became aware of the many faces, the indistinctness of its vision seemed to take on outline and form. Perhaps for a second it had a sight of the world and of men, and that sight was to it a source of boundless horror. It trembled as in a fever; it uttered a piercing cry of lamentation; it fled, and when the trainer tried to grasp it, it leaped from the platform and frantically sought a hiding-place. Tears glittered in its eyes and its teeth chattered, and in spite of the animal characteristics of these gestures and expressions, there was in them something so human and soulful that only a few very coarse people ventured to laugh. To Christian there came from the little beast a breath from an alien region of earth and forests and loneliness. His heart seemed to expand and then to contract. “Let us go,” he said, and his own voice sounded unpleasantly in his ears. Johanna listened to his words. She was all willingness to listen, all tension and all sweet humility. XIII Randolph von Stettner had arrived. There were still several days before the date of his sailing, and he was on his way to Lübeck, where he wished to say good-bye to a married sister. Christian hesitated to promise to be in Hamburg on his friend’s return. Only after much urging did he consent to stay. They dined in Christian’s room, discussed conditions in their native province, and exchanged reminiscences. Christian, laconic as usual, was silently amazed at the distance of all these things from his present self.
  • 77. When the waiter had removed the dishes, Stettner gave an account of all that had driven him to the determination to expatriate himself. While he talked he stared with an unchanging look and expression at the table cover. “You know that for some years I’ve not been comfortable in my uniform. I saw no aim ahead except the slow and distant moments of advancement. Some of my comrades hoped for war. Well, the life makes that hope natural. In war one can prove one’s self in the only way that has any meaning to a professional soldier in any army. But personally I couldn’t share that hope. Others marry money, still others go in for sports and gambling. None of these things attracted me. The service itself left me utterly dissatisfied. I seemed to myself in reality an idler who lives pretentiously on others. “Imagine this: you stand in the barracks yard; it’s raining, the water makes the sand gleam; the few wretched trees drip and drip; the men await some command with the watchfulness of well-trained dogs; the water pours from their packs, the sergeant roars, the corporals grit their teeth in zeal and rage; but you? With a monotony like that of the drops that trickle from your cap, you think: ‘What will to-night be like? And to-morrow morning? And to-morrow night?’ And the whole year lies ahead of you like a soaked and muddy road. You think of your desolate room with its three dozen books, the meaningless pictures, and the carpet worn thin by many feet; you think of the report you’ve got to hand in, and the canteen accounts you’ve got to audit, and the stable inspection, and the next regimental ball, where the arrogant wives of your superior officers will bore you to the point of illness with their shallow talk; you think your way through the whole circle of your life, and find nothing but what is trivial and cheerless as a rainy day. Is that endurable? “One day I put the question to myself: What was I really accomplishing, and what was the nature of my reward? The answer was that, from a human and intellectual point of view, my accomplishment was an absolute zero. My reward consisted of a number of privileges, the sum of which raised me very high in the
  • 78. social scale, but gave me this position only at the cost of surrendering my personality wholly. I had to obey my superiors and to command my inferiors. That was all. The power to command was conditioned in the duty to obey. And each man in the service, whatever his station, is bound in the identical way, and is simply a connective apparatus in a great electrical circuit. Only the humblest, the great mass of privates, were confined to obedience. The ultimate responsibility at the very top was lost in the vague. In spite of its ultimate primitiveness, the structure of every military organization has a mystery at its core. But between the arbitrary will of a very few and the touching and incomprehensible humility of the great mass, the parts function according to iron laws. Whoever refuses to function, or rebels, is crushed. “There are those who assert that this compulsion has a moral effect and subserves a higher conception of freedom. I was myself of that opinion for a long time; but I did not find it permanently tenable. I felt myself weakening, and a rebellion seething in my blood. I pulled myself together, and fought against criticism and doubt. In vain. Something had gone out of me. I lost the readiness to obey and the security to command. It was torment. Above me I saw implacable idols, below me defenceless victims. I myself was both idol and victim, implacable and defenceless at once. It seemed to me that humanity ceased where the circle of my activity began. My life seemed to me no longer a part of the general life of mankind, but a fossilized petrefaction conditioned in certain formulæ of command and obedience. “This condition could, of course, not remain hidden. My comrades withdrew their confidence from me. I was observed and distrusted. Before I had time to clarify either my mind or my affairs, an incident occurred which forced me to a decision. A fellow officer in my regiment, Captain von Otto, was engaged to the daughter of an eminent judge. The wedding, although the date had been set, could not take place. Otto had a slight attack of pulmonary trouble and had to go South for cure. About four weeks after his departure, there was a celebration in honour of the emperor’s birthday, and
  • 79. among the ladies invited was the captain’s betrothed. Everybody was rather gay and giddy that evening, especially a dear friend of mine, Georg Mattershausen, a sincere, kindly chap who had just received a promotion in rank. The captain’s betrothed, who had been his neighbour at table, was infected by his merriment, and on the way home he begged her for a kiss. She refused, and he was going to steal one. She now grew very serious; he at once came to his senses, apologized with the utmost sincerity, and, at the very door of her paternal house, received her solemn promise to mention the incident to no one. When, however, seventeen weeks later, Captain von Otto returned, the girl was seized by some queer scruple, and thought it her duty to tell him of the incident between herself and Mattershausen. The result was a challenge. The conditions were extraordinarily severe: ten paces distance, drawn revolvers, half a minute to aim, exchange of shots to the disablement of either combatant. I was Mattershausen’s second. Otto, who had held himself to be affronted and had sent the challenge, had the first shot. He aimed carefully at the head of his adversary. I saw that. But the bullet whistled past my friend’s ear. Mattershausen aimed, but his revolver did not go off. This was counted a shot. New pistols were brought. Otto aimed as carefully as before and this time shot Mattershausen straight through the heart. Death was immediate. “I wonder whether you, too, think that that was a harsh punishment for a moment of youthful thoughtlessness and impropriety. To me it seemed terribly harsh. I felt profoundly that a crime had been committed against my friend. Our fossilized caste had perpetrated a murder. Two days later, in the officers’ mess, I expressed this opinion quite frankly. There was general astonishment. One or two sharp replies were made. Some one asked me what I would have done in such a situation. I answered that I would certainly not have sent a challenge, that I could never approve a notion of honour so morbid and self-centred as to demand a human life for a trifle. Even if the young girl’s over-tender conscience had persuaded her to break her promise, I would have caused no further trouble, and let the little incident glide into forgetfulness. At that there was general
  • 80. indignation—a great shaking of heads, angry or troubled faces, an exchange of significant glances. But I kept on. Mattershausen’s wretched end had hit me damned hard, and I relieved my whole mind. So I added that, if I had been in Mattershausen’s place, I would have refused the challenge, quite regardless of consequences. That statement fell among them like a bomb, and a painful silence followed. ‘I imagine you would have reconsidered,’ said the ranking major, ‘I don’t think you would have disregarded all the consequences.’ ‘All,’ I insisted, ‘certainly, all!’ At that moment Captain von Otto, who had been sitting at another table, arose, and asked frostily: ‘You would have risked the odium of cowardice?’ I too arose, and answered: ‘Under such circumstances I would have risked that too.’ Captain von Otto smiled a contorted smile, and said with an emphasis that could not be misinterpreted: ‘Then I don’t understand your sitting at the same table with officers of His Majesty.’ He bowed stiffly, and went out. “The die had been cast. No one was curious as to what I would do; no one doubted but that there was only one thing left for me to do. But I was determined to push the matter to its logical conclusion. That super-idol, known as the code of honour, had issued its decree; but I was determined to refuse obedience and take the consequences upon myself. That very evening, when I came home, two comrades were awaiting me to offer me their services. I refused courteously. They looked at me as though I had gone mad, and went off in absurd haste. “The inevitable consequences followed. You can understand that I could no longer breathe in that air. You cannot outrage the fetishes of your social group and go unpunished. I had to avoid insult, and learned what it was to be an outcast. And that is bad. The imagination alone cannot quite grasp the full horror of it. I saw clearly that there was no place left for me in my fatherland. The way out was obvious.” Christian had listened to his friend’s story with unmoved countenance. He got up, took a few turns through the room, and
  • 81. returned to his seat. Then he said: “I think you did the right thing. I am sorry you must leave us, but you did right.” Stettner looked up. How strange that sounded: You did right. A question hovered on his lips. But it was not uttered. For Christian feared that question, and silenced it by a sudden conventionality of demeanour. XIV Christian, the brothers Maelbeek, who had followed Eva from Holland, Botho von Thüngen, a Russian councillor of state named Koch, and Crammon sat at luncheon in the dining hall of the hotel. They were talking about a woman of the streets who had been murdered. The police had already caught the murderer. He was a man who had once belonged to good society, but had gradually gone to the dogs. He had throttled the woman and robbed her in a sailor’s tavern. Now all the prostitutes in the city had unanimously determined to show their sister, who had sacrificed her life to her calling, a last and very public mark of respect, and to follow her coffin to the grave. The respectable citizens of Hamburg felt this to be a sort of challenge and protested. But there was no legal provision by which the demonstration could be stopped. “We ought to see the spectacle,” said Crammon, “even if we have to sacrifice our siesta.” “Then there’s no time to be lost,” the elder Maelbeek declared, and looked at his watch. “The friends will assemble at the house of mourning at three sharp.” He smiled, and thought this way of putting the matter rather witty. Christian said that he would go too. The motor took them to a crossing that had been closed by the police. Here they left the car,
  • 82. and Herr von Thüngen persuaded the police captain to let them pass. They were at once surrounded by a great throng of humble folk— sailors, fishermen, workingmen, women, and children. The windows of the houses were thronged with heads. The Maelbeeks and Koch stopped here, and called Thüngen to join them. Christian walked farther. Somehow the behaviour of his companions irritated him. He felt the kind of curiosity which filled them as something disagreeable. He was curious too, but in another way. Or, at least, it seemed different to him. Crammon remained by his side. But the throng grew rowdy. “Where are you going?” Crammon asked peevishly. “There is no use in going farther. Let us wait here.” Christian shook his head. “Very well. I take my stand here,” Crammon decided, and separated from Christian. The latter made his way up to the dirty, old house at the door of which the hearse was standing. It was a foggy day. The black wagon was like a dark hole punched into the grey. Christian wanted to go a little farther, but some young fellows purposely blocked his way. They turned their heads, looked him over, and suspected him of being a “toff.” Their own garb was cheap and flashy; their faces and gestures made it clear what trade they drove. One of them was a young giant. He was half a head taller than Christian, and his brows joined over the bridge of his nose. On the index finger of his left hand he wore a huge carnelian ring. Christian looked about him quite unintimidated. He saw hundreds of women, literally hundreds, ranging in age from sixteen to fifty, and in condition from bloom to utter decay, and from luxury to rags and filth. They had all gathered—those who had passed the zenith of their troubled course, and those who had barely emerged from childhood, frivolous, sanguine, vain, and already tainted with the mire of the
  • 83. great city. They had come from all streets; they were recruited from all nations and all classes; some had escaped from a sheltered youth, others had risen from even direr depths; there were those who felt themselves pariahs and had the outcast’s hatred in their eyes, and there were others who showed a certain pride in their calling and held themselves aloof. He saw cynical and careworn faces, lovely and hardened ones, indifferent and troubled, greedy and gentle faces. Some were painted and some pallid; and the latter seemed strangely naked. He was familiar with them from the streets and houses of many cities, as every man is. He knew the type, the unfailing stamp, the acquired gesture and look—this hard, rigid, dull, clinging, lightless look. But he had never before seen them except when they were exercising their function behind the gates of their calling, dissembling their real selves and under the curse of sex. To see many hundreds of them separated from all that, to see them as human beings stripped of the stimulus and breath of a turbid sexuality—that was what seemed to sweep a cloud from his eyes. Suddenly he thought: “I must order my hunting lodge to be sold, and the hounds too.” The coffin was being carried from the house. It was covered with flowers and wreaths; and from the wreaths fluttered ribands with gilt inscriptions. Christian tried to read the inscriptions, but it was impossible. The coffin had small, silver-plated feet that looked like the paws of a cat. By some accident one of these had been broken off, and that touched Christian, he hardly knew why, as unbearably pitiful. An old woman followed the coffin. She seemed more vexed and angry than grief-stricken. She wore a black dress, but the seam under one arm was ripped open. And that too seemed unbearably pitiful. The hearse started off. Six men carrying lighted candles walked in front of it. The murmur of voices became silent. The women, walking by fours, followed the hearse. Christian stood still close pressed against a wall, and let the procession pass him by. In a
  • 84. quarter of an hour the street was quite desolate. The windows of the houses were closed. He remained alone in the street, in the fog. As he walked away he reflected: “I’ve asked my father to take care of my collection of rings. There are over four thousand of them, and many are beautiful and costly. They could be sold too. I don’t need them. I shall have them sold.” He wandered on and on, and lost all sense of the passing of time. Evening came, and the city lights glowed through the fog. Everything became moist, even to the gloves on his hands. He thought of the missing foot on the coffin of the murdered harlot, and of the torn seam of the old woman’s dress. He passed over one of the great bridges of the Elbe, and then walked along the river bank. It was a desolate region. He stopped near the light of a street lamp, gazed into the water, drew forth his wallet, took out a bank note of a hundred marks, turned it about in his hands, shook his head, and then, with a gesture of disgust, threw it into the water. He took a second and did the same. There were twenty bank notes in his wallet. He took them out one by one, and with that expression half of disgust, half of dreaminess, he let them glide into the river. The street lamps illuminated the inky water for a short distance, and he saw the bank notes drift away. And he smiled and went on. XV When he reached the hotel he felt an urgent need of warmth. By turns he entered the library, the reception hall, the dining-room. All these places were well heated, but their warmth did not suffice him. He attributed his chill to walking so long in the damp.
  • 85. He took the lift and rode up to his own rooms. He changed his clothes, wrapped himself warmly, and sat down beside the radiator, in which the steam hissed like a caged animal. Yet he did not grow warm. At last he knew that his shivering was not due to the moisture and the fog, but to some inner cause. Toward eleven o’clock he arose and went out into the corridor. The stuccoed walls were divided into great squares by gilt moulding; the floor was covered by pieces of carpet that had been joined together to appear continuous. Christian felt a revulsion against all this false splendour. He approached the wall, touched the stucco, and shrugged his shoulders in contempt. At the end of the long corridor was Eva’s suite. He had passed the door several times. As he passed it again he heard the sound of a piano. Only a few keys were being gently touched. After a moment’s reflection he knocked, opened the door, and entered. Susan Rappard was alone in the room. Wrapped in a fur coat, she sat at the piano. On the music rack was propped a book that she was reading. Her fingers passed with ghostly swiftness over the keys, but she struck one only quite rarely. She turned her head and asked rudely: “What do you want, Monsieur?” Christian answered: “If it’s possible, I should like to speak to Madame. I want to ask her a question.” “Now? At night?” Susan was amazed. “We’re tired. We’re always tired at night in this hyperborean climate, where the sun is a legend. The fog weighs on us. Thank God, in four days we have our last performance. Then we’ll go where the sky is blue. We’re longing for Paris.” “I should be very happy if I could see Madame,” Christian said. Susan shook her head. “You have a strange kind of patience,” she said maliciously. “I hadn’t suspected you of being so romantic. You’re pursuing a very foolish policy, I assure you. Go in, if you want to, however. Ce petit laideron est chez elle, demoiselle Schöntag. She
  • 86. acts the part of a court fool. Everything in the world is amusing to her—herself not least. Well, that is coming to an end too.” Voices and clear laughter could be heard. The door of Eva’s rooms opened, and she and Johanna appeared on the threshold. Eva wore a simple white garment, unadorned but for one great chrysoprase that held it on the left shoulder. Her skin had an amber gleam, the quiver of her nostrils betrayed a secret irritation. The beautiful woman and the plain one stood there side by side, each with an acute feminine consciousness of her precise qualities: the one vital, alluring, pulsing with distinction and freedom; the other all adoration and yearning ambition for that vitality and that freedom. Tenderly and delicately Johanna had put her arm about Eva and touched her friend’s bare shoulder with her cheek. With her bizarre smile she said: “No one knows how it came that Rumpelstilzkin is my name.” They had not yet observed Christian. A gesture of Susan’s called their attention to him. He stood in the shadow of the door. Johanna turned pale, and her shy glance passed from Eva to Christian. She released Eva, bowed swiftly to kiss Eva’s hand, and with a whispered good-night slipped past Christian. Although Christian’s eyes were cast down, they grasped the vision of Eva wholly. He saw the feet that he had once held naked in his hands; under her diaphanous garment he saw the exquisite firmness of her little breasts; he saw the arms that had once embraced him and the perfect hands that had once caressed him. All his bodily being was still vibrantly conscious of the smoothness and delicacy of their touch. And he saw her before him, quite near and hopelessly unattainable, and felt a last lure and an ultimate renunciation. “Monsieur has a request,” said Susan Rappard mockingly, and preparing to leave them. “Stay!” Eva commanded, and the look she gave Christian was like that she gave a lackey.
  • 87. “I wanted to ask you,” Christian said softly, “what is the meaning of the name Eidolon by which you used to call me. My question is belated, I know, and it may seem foolish to-day.” He smiled an embarrassed smile. “But it torments me not to know when I think about it, and I determined to ask you.” Susan gave a soundless laugh. In its belated and unmotivated urgency, the question did, indeed, sound a little foolish. Eva seemed amused too, but she concealed the fact. She looked at her hands and said: “It is hard to tell you what it means—something that one sacrifices, or a god to whom one sacrifices, a lovely and serene spirit. It means either or perhaps both at once. Why remind ourselves of it? There is no Eidolon any more. Eidolon was shattered, and one should not exhibit the shards to me. Shards are ugly things.” She shivered a little, and her eyes shone. She turned to Susan. “Let me sleep to-morrow till I wake. I have such evil dreams nowadays, and find no rest till toward morning.” XVI Passing back through the corridor Christian saw a figure standing very still in the semi-darkness. He recognized Johanna, and he felt that this thing was fated—that she should be standing here and waiting for him. She did not look at him; she looked at the floor. Not until he came quite close to her did she raise her eyes, and then she looked timidly away. Her lips quivered. A question hovered on them. She knew all that had passed between Eva and Christian. That they had once been lovers only increased her enthusiastic admiration for them both. But what happened between them now—her brief presence made her sure of its character—seemed to her both shameful and incomprehensible.
  • 88. She was imaginative and sensitive, and loved those who were nobly proud; and she suffered when such noble pride and dignity were humbled. Her whole heart was given over to her ideal of spiritual distinction. Sometimes she would misunderstand her own ideal, and take external forms and modes as expressions of it. And this division in her soul, to which she was not equal, sometimes delivered her into the power of mere frivolity. “It is late,” she whispered timidly. It was not a statement; it was an attempt to save herself. Each time that Christian had been mentioned, three things had struck her mind: his elegance, his fine pride, his power over all hearts. That was the combination that called to her and stirred her and filled her days with longing. Thus she had followed Crammon in search of the great adventure, although she had said of him but an hour after she had met him: “He is grandiosely and grotesquely comic.” She had followed him like a slave to a market of slaves, hoping to catch the eye of the khalif. But she had no faith in her own power. Voluntarily and intentionally she crumbled the passions of her being into small desires. She suffered from that very process and jeered at herself. She was too timid to take greatly what she wanted. She nibbled at life and had not the adventurousness of great enjoyments. And she mocked at her own unhappy nature, and suffered the more. And now he stood before her. It frightened and surprised her, even though she had waited for him. Since he stayed, she wanted to think him bold and brave. But she could not, and at once she shrank into self-contempt. “It is late,” she whispered again, nodded a good- night, and opened the door of her room. But Christian begged silently with an expression that was irresistible. He crossed the threshold behind the trembling girl. Her face grew hard. But she was too fine to play a coquettish game. Before her blood was stirred her eyes had yielded. The pallor of her face lit it with a new charm. There was no hint of plainness any more. The stormy expectation of her heart harmonized the lines of her features and melted them into softness, gentleness, and delicacy.
  • 89. Of her power over the senses of men she was secure. She had tested her magnetism on those whom one granted little and who gave less. Flirtations had been used as anodynes in her social group. One had played with false counters, and by a silent compact avoided serious moments. But her experience failed her to-night, for here there was not lightness but austerity. She yielded herself to this night, oblivious of the future and its responsibilities. XVII Stephen Gunderam had to go to Montevideo. In that city there was a German physician who had considerable skill in the treatment of nervous disorders; and the bull-necked giant suffered from insomnia and nocturnal hallucinations. Furthermore, there was to be a yacht race at Montevideo, on the results of which Stephen had bet heavily. He appointed Demetrios and Esmeralda as Letitia’s guardians. He said to them: “If anything happens to my wife or she does anything unseemly, I’ll break every bone in your bodies.” Demetrios grinned. Esmeralda demanded that he bring her a box of sweets on his return. Their leave-taking was touching. Stephen bit Letitia’s ear, and said: “Be true to me.” Letitia immediately began to play upon the mood of her guardians. She gave Demetrios a hundred pesos and Esmeralda a gold bracelet. She corresponded secretly with the naval lieutenant, Friedrich Pestel. An Indian lad, of whose secrecy and reliability she was sure, served as messenger. Within a week Pestel’s ship was to proceed to Cape Town, so there was little time to be lost. He did not think he would be able to return to the Argentine until the following winter. And Letitia loved him dearly. Two miles from the estate there was an observatory in the lonely pampas. A wealthy German cattle-man had built it, and now a
  • 90. Welcome to our website – the perfect destination for book lovers and knowledge seekers. We believe that every book holds a new world, offering opportunities for learning, discovery, and personal growth. That’s why we are dedicated to bringing you a diverse collection of books, ranging from classic literature and specialized publications to self-development guides and children's books. More than just a book-buying platform, we strive to be a bridge connecting you with timeless cultural and intellectual values. With an elegant, user-friendly interface and a smart search system, you can quickly find the books that best suit your interests. Additionally, our special promotions and home delivery services help you save time and fully enjoy the joy of reading. Join us on a journey of knowledge exploration, passion nurturing, and personal growth every day! ebookbell.com