50% found this document useful (2 votes)
56 views

Programming Kotlin Enhance your skills for Android development using Kotlin 2nd Edition Alexander Aronowitz All Chapters Instant Download

Programming

Uploaded by

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

Programming Kotlin Enhance your skills for Android development using Kotlin 2nd Edition Alexander Aronowitz All Chapters Instant Download

Programming

Uploaded by

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

Download the Full Version of textbook for Fast Typing at textbookfull.

com

Programming Kotlin Enhance your skills for Android


development using Kotlin 2nd Edition Alexander
Aronowitz

https://textbookfull.com/product/programming-kotlin-enhance-
your-skills-for-android-development-using-kotlin-2nd-
edition-alexander-aronowitz/

OR CLICK BUTTON

DOWNLOAD NOW

Download More textbook Instantly Today - Get Yours Now at textbookfull.com


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

Android Studio Iguana Essentials Kotlin Edition Developing


Android Apps Using Android Studio 2023 2 1 and Kotlin Neil
Smyth
https://textbookfull.com/product/android-studio-iguana-essentials-
kotlin-edition-developing-android-apps-using-android-
studio-2023-2-1-and-kotlin-neil-smyth/
textboxfull.com

Android Apprentice Second Edition Beginning Android


Development with Kotlin Darryl Bayliss

https://textbookfull.com/product/android-apprentice-second-edition-
beginning-android-development-with-kotlin-darryl-bayliss/

textboxfull.com

Android Apprentice Fourth Edition Beginning Android


Development with Kotlin Namrata Bandekar

https://textbookfull.com/product/android-apprentice-fourth-edition-
beginning-android-development-with-kotlin-namrata-bandekar/

textboxfull.com

Kotlin Apprentice Second Edition Beginning Programming


with Kotlin Irina Galata

https://textbookfull.com/product/kotlin-apprentice-second-edition-
beginning-programming-with-kotlin-irina-galata/

textboxfull.com
Programming Android With Kotlin: Achieving Structured
Concurrency With Coroutines Pierre-Olivier Laurence

https://textbookfull.com/product/programming-android-with-kotlin-
achieving-structured-concurrency-with-coroutines-pierre-olivier-
laurence/
textboxfull.com

Programming Kotlin Create Elegant Expressive and


Performant JVM and Android Applications 1st Edition Venkat
Subramaniam
https://textbookfull.com/product/programming-kotlin-create-elegant-
expressive-and-performant-jvm-and-android-applications-1st-edition-
venkat-subramaniam/
textboxfull.com

Programming Kotlin Applications Building Mobile and Server


Side Applications with Kotlin 1st Edition Brett Mclaughlin

https://textbookfull.com/product/programming-kotlin-applications-
building-mobile-and-server-side-applications-with-kotlin-1st-edition-
brett-mclaughlin/
textboxfull.com

How to Build Android Apps with Kotlin A practical guide to


developing testing and publishing your first Android apps
2nd Edition Alex Forrester
https://textbookfull.com/product/how-to-build-android-apps-with-
kotlin-a-practical-guide-to-developing-testing-and-publishing-your-
first-android-apps-2nd-edition-alex-forrester/
textboxfull.com

Programming DSLs in Kotlin 1st Edition Venkat Subramaniam


[Subramaniam

https://textbookfull.com/product/programming-dsls-in-kotlin-1st-
edition-venkat-subramaniam-subramaniam/

textboxfull.com
................................................ Introducing Kotli n
............................................
.................................................. .................................................. ?Why Kotlin
...
.................................................. ?Who is this book for
...........................................
................................ .............................................. How to use this book
............................................ ................................................ For the curious
....... .................................................. ................................................. Tasks
............................... ................................................ Typographic conventions
............................................... ................................................ Looking ahead
................................................ From the publisher
.............................................

............................................. Chapte r 1 . Your first Kotlin application


............
.................................... ............................................... Installing IntelliJ IDEA
..................................... ............................................. Your first Kotlin project
.................................. ............................................. Your first Kotlin file
.................... ............................................ Running your file in Kotlin language
.................................................. ................................................ Kotlin REPL
...........
.... .................................................. ?For the curious: why use IntelliJ
.......... ............................................ For the curious: programming for the JVM
.............................................. Assignment: REPL arithmetic
......................................
............................................. Chapte r 2 . Variables, constants and types
......................
.................................................. ................................................. Types
..................
....................................... ................................................ Variable declaration
.................................. .............................................. Kotlin built-in types
............... ............................................ Read-only variables
....................... ............................................... Automatic type detection
............................. ............................................... Compile Time Constants
............................................. Exploring Kotlin Bytecode
............................................
.............. .......................................... For the curious: Java simple types in Kotlin
............................................... Quest: hasSteed
..................................................
......................................... ............................................ Quest: Unicorn Horn
................................... .............................................. Quest: Magic Mirror

................................................ Chapte r 3 . Conditional constructions


.................................
.............................................. If / else statements
... ..................................................
........................................ ................................................ Adding conditions
.............................. ............................................. Nested if / else statements
............. .............................................. More elegant conditionals
.................................................. ................................................. Intervals
..........
............................................... When conditional expression
....................................
................................................ Template strings
................................................
.............................................. Assignment: trying intervals
..................................
Task: displaying extended information about the aura
.... ...........................................
... ............................................ Assignment: Customizable Status Bar Format
................................................. Chapte r 4 . Functions
... ..................................................
.............................................. Highlighting code in a function
.....................................
................................................ Anatomy of function
................................................
.......................................... ................................................ Function header
.................................................. ................................................ Function body
.
............................. ............................................... Function scope
.................................................. ................................................ Function call
....
................................................ Function refactoring
...........................................
...................................... ............................................... We write our functions
....................................... ............................................... Default arguments
.................... .............................................. Functions with a single expression
....................... ............................................. Functions with the return type Unit
.......................... ............................................... Named function arguments
............................................. For the curious: the Nothing type
..................................
......... .......................................... For the curious: file-level functions in Java
............................................. For the curious: function overloading
.....................
........................................ For the curious: function names in backticks
..... ............................................ Assignment: functions with a single expression
..................... ............................................. Quest: intoxicating effect of fireball
....................... .............................................. Assignment: intoxicated state

Chapte r 5 . Anonymous functions and functional types


...........................................
................................................ Anonymous functions
............................................
................................... ................................................ Functional types
................................................. ................................................ Implicit return
................................ ................................................ Functional arguments
................................................. ............................................... Keyword it
....................... ............................................... Taking multiple arguments
... .............................................. Support for automatic type detection
............................................ Function declaration that takes a function
...................................... ................................................ Abbreviated syntax
........................................... ................................................ Built-in functions
.............................................. ............................................... Function link
...................... ............................................. Function type as return type
..... .......................................... For the curious: Kotlin lambdas are closures
...................... For the curious: lambdas vs. anonymous inner classes

............................................. Chapte r 6 . Null safety and exceptions


...................
.................................................. ................................................. Nullability
..........
............................................. Explicit type null in Kotlin
............................................
................. ............................................. Compile time and run time
................................................. ............................................... Null safety
. ............................................ First Option: Safe Call Operator
............................... ............................................ !! Option two: operator
.................................. Third option: check the value for null
.................................................. ................................................. Exceptions
......
.............................. ................................................ Raising Exceptions
....................... ................................................ Custom Exceptions
.................................. ................................................ Exception Handling
.......................................... ................................................ Checking conditions
.................................................. ?Null: what's good about it
..................................
........................... For the curious: checked and unchecked exceptions
....................................... ?For the curious: how is null support provided
................................................. Chapte r 7 . Strings
.... ..................................................
................................................ Extracting a substring
.........................................
...... .................................................. ................................................. substring
............. .................................................. ................................................. split
............................................... Working with strings
..............................................
...................................... ................................................ Strings are immutable
................................................ String comparison
..................................................
..................................... .............................................. For the curious: Unicode
........................................... For the curious: traversing characters in a string
..............
............................................. Quest: Improve Draconic Language
.........................

................................................. Chapte r 8 . Numbers


..... ..................................................
.................................................. ................................................ Numeric types
..
.................................... ................................................​​Integer values
................................................ Fractional numbers
.. ..................................................
............................ .............................................. Convert string to number
................................. .............................................. Converting Int to Double
................. ..............................................​​Formatting Double Values
................................. .............................................. Converting Double to Int
................ ............................................ For the curious: bit manipulation
............................................. Assignment: How Many Pints ​R emain
.............................
......... ............................................. Task: Handling Negative Balance
.................................... .............................................. Quest: Dragon Coins
................................................ Chapte r 9 . Standard functions
..............................
.................................................. ................................................. apply
.................
.................................................. ................................................. let
.....................
.................................................. ................................................. run
...................
.................................................. ................................................. with
..................
.................................................. ................................................. also
...................
.................................................. ................................................. takeIf
................
.................................................. ................................................. takeUnless
.........
................... ............................................... Using standard functions

............................................... Chapte r 10. Lists and Sets


.................................
.................................................. ................................................. Lists
..............
................................... .............................................. Access to list items
....................................... Index Boundaries and Secure Index Access
............................................... Checking the contents of the list
.............................
............................................... Changing the contents of the list
..................................
.................................................. ................................................. Iteration
..........
.............................................. Reading a file into a list
..........................................
............................................... ................................................. Destructuring
....... .................................................. ................................................. Sets
...................................... ................................................ Creating a set
................. .............................................. Adding items to a set
.................................................. ................................................ While loop
.........
................................................ The break statement
.. ..................................................
................................. ................................................ Converting Collections
........................... ............................................. For the curious: array types
....................... "For the curious: "read-only" instead of "immutable
............................................ Assignment: Formatted Display of the Tavern Menu
...
........................................ Quest: Improved Tavern Menu Formatting

................................................ Chapte r 11. Associative arrays


..........................
........................ ............................................... Creating an associative array
......... ............................................ Accessing values ​in an associative array
............ ............................................. Add entries to the associative array
........ ............................................. Changing the values ​in the associative array
................................ ............................................. Quest: Tavern Bouncer

............................................. Chapte r 12. Declaring Classes


...................................
.............................................. ................................................ Class declaration
........................................... ................................................ Creating instances
................................................ Class functions
. ..................................................
............................................... Availability and Encapsulation
................................
................................................ Class properties
..................................................
................................................ Property methods
. ..................................................
.............................................. ................................................ Property Visibility
........................................ ................................................ Computed Properties
................................................ Refactoring NyetHack
.........................................
....................................... ................................................ Using packages
.................... For the curious: a closer look at the var and val properties
........................................... For the curious: protection against race conditions
..........
For the curious: limiting visibility to the scope of the package
.................................

.............................................. Chapte r 13. Initialization


........................................
.................................................. ................................................. Constructors
...
........................................... ................................................ Chief Designer
......... ............................................. Declaring properties in the main constructor
........................... ................................................ Helper Constructors
..................................... ............................................... Default arguments
..................................... ................................................ Named arguments
........................................... ................................................ Initialization block
....................................... ................................................ Property initialization
...................................... ................................................ Initialization order
.................................... ................................................ Initialization delay
...................................... ................................................ Late initialization
............................... ................................................ Delayed initialization
........................................... For the curious: initialization pitfalls
.............................................. Quest: the riddle of Excalibur
...............................

................................................. Chapte r 14. Inheritance


.........................................
..................................... ............................................... Room class declaration
............................................ ................................................ Subclassing
. .................................................. ................................................ Type check
............................................. Type hierarchy in Kotlin language
................................
................................................. ................................................ Type casting
........................................ ............................................... Clever type casting
........................................... .............................................. For the curious: Any

................................................. Chapte r 15. Objects


.................................................
.......................................... ............................................... The object keyword
.......................................... ................................................ Object declarations
................................................ Anonymous objects
............................................
................................... ................................................ Auxiliary facilities
.............................................. ................................................ Nested classes
.. .................................................. ................................................ Data classes
........ .................................................. ................................................. toString
.......... .................................................. ................................................. equals
............ .................................................. ................................................. copy
....................... ................................................ Destructuring ads
... .................................................. ................................................. Transfers
....................................... ................................................ Operator overloading
............................................... Explore the world of NyetHack
.......................................
....................................... For the curious: declaring a structural comparison
...... ............................................ For the curious: algebraic data types
............................................ "Assignment: command "Quit
.........................................
............................................. Assignment: Implementation of the World Map
...........................
................................ ............................................. Assignment: ring the bell
Introducing Kotlin
In 2011, JetBrains announced the development of a programming
language
Kotlin as an alternative to Java and Scala, which also works
running a Java Virtual Machine. Six years later, Google announced
the beginning of official support for Kotlin, as a development
.language for the Android operating system
Kotlin has grown rapidly from a bright future language to
application support language of the world's leading operating
.system
Today big companies like Google, Uber, Netflix, Capital One,
Amazon and others have officially adopted Kotlin for its
convenience, understandable
.syntax, modern features and full Java compatibility

?Why Kotlin
To appreciate the attractiveness of Kotlin, you should first figure out
which
Java occupies a place in the modern world of software
development. The Kotlin code is runs under the Java Virtual
Machine, so the two languages ​are closely
.interrelated
Java is the most trusted and reliable language used for
developing industrial applications for many years. But the language
Java was created back in 1995, and since that time, the criteria for
evaluating good programming languages ​have changed. Java lacks
many of the conveniences it has in languages ​used by developers
now. Kotlin creators have checked out lessons from design decisions
made when designing Java (and other languages ​such as Scala) and
have lost their relevance. Its development went beyond the limits of
the capabilities of old languages ​and it has been corrected a lot that
caused a lot of inconvenience. Learn how Kotlin is better than Java
.in this book
.and why it is more convenient to work with it
Kotlin is not just an improved language for the Java Virtual Machine.
It is multi- general-purpose platform language: you can write
applications in Kotlin
Introducing Kotlin for Windows and MacOS, JavaScript and of course
Android. Independence from the system implies a wide range of
.Kotlin applications

?Who is this book for


We've written this book for developers of all sizes: seasoned
Android
developers who lack Java capabilities, server developers good code
interested in Kotlin features, as well as for beginners, decided to
.learn an efficient compiled language
This book may interest you in Android support, but it is not limited
to
It is done in Kotlin programming for Android. Moreover, in this book
only
one chapter - chapter 21 - covers programming techniques in Kotlin
for Android. Nevertheless, if you are interested in the topic of using
Kotlin for
Android Application Development, this book will introduce you to
the basic
Themes that will simplify the process of writing Android applications
.in Kotlin
Even though Kotlin has been influenced by several other languages,
you
there is no need to know how they work in order to work
successfully with Kotlin. Time from time to time we will compare
Java and Kotlin code. If you have experience development in Java,
it will help you understand the relationship between the two
.languages
And if you don't have such experience, examples of solving the
same problems in another language help you understand the ideas
.behind Kotlin

How to use this book


This book is not intended to be a reference. Our goal is consistent
learning
the Kotlin language. You will work on projects and learn the
.language as you work
For more effect, we recommend trying out all the code examples
.along the way
reading a book. Working with examples will help you develop
muscle memory
and will provide an understanding that allows you to move from one
.chapter to another
Each next chapter builds on the previous one. We recommend not
skip chapters. Even if you have studied the topic while working with
other languages, we suggest at least reading about it here: a lot is
implemented in Kotlin otherwise. We'll start with introductory topics
like variables and lists and then let's move on to the techniques of
object-oriented and functional pro
grammar to give you an idea of ​what makes Kotlin so powerful tool.
.By the end of the book, you will go from beginner to advanced
.developer in Kotlin
We want to add that there is no need to rush: develop, use
documentary See the Kotlin reference at kotlinlang.org/docs/reference ,
where there are answers to many
.questions arising during the experiments

For the curious


Most of the chapters have a For the Curious section. There are
revealed
principles of the Kotlin language. Examples in chapters are not
directly related to this information. These sections provide
additional information that
.can be useful to you

Tasks
Most of the chapters end with one or two tasks. Their solution
will help you understand the Kotlin language better. We propose to
.perform them for mastering the Kotlin language

T ypographic conventions
In the process of developing projects from the book, we will support
you, revealing introduce a topic and then show you how to put
theory into practice. For more For clarity, we adhere to certain
.typographic conventions
Variables, their values ​and types are printed in monospaced font.
-Klas
.Sy, functions, and interface names are in bold
All listings with code are printed in monospaced font. If you need
will add the code in the listing, this code will be highlighted in bold.
If the code you need to remove it from the listing, it will be crossed
out. In the example below
at least you are told to remove the line of code that declares
: variable y , and adding the variable z to the code

"var x = "Python
"var y = "Java
"var z = "Kotlin
Kotlin is a relatively young language, so many conventions about
the design of the code is still being formed. As time goes by, you
are more likely all, develop your own style, but first read the
JetBrains requirements
:and google

JetBrains Agreement: kotlinlang.org/docs/reference/coding- ❍


. conventions.html

Google Style Guide containing styling conventions ❍


. and android code compatibility: android.github.io/kotlin-guides/style.html

Looking ahead
Take your time to bring the examples in this book to life. Having
mastered the syntax Kotlin, you will make sure that the
development process in this language is clear, flexible cue and
pragmatic. Until that happens, just carry on
.get to know him: learning a new language is always beneficial

From the publisher


Send your comments, suggestions, questions to [email protected]
.)publishing house "Peter", computer edition(
!We'd love to hear from you
On the publisher's website www.piter.com you will find detailed
information
.about our books

Your first application 1


on Kotlin
In this chapter, you will write your first Kotlin program using
IntelliJ IDEA. By going through this rite of passage into
programming, you learn
chat with the development environment, create a new Kotlin project
in it, write
.and run the code, and you will also see the results of its execution

Installing IntelliJ IDEA


IntelliJ IDEA is an integrated development environment
environment, IDE) for the Kotlin language, created by the JetBrains
team (which also created by Kotlin itself). Download IntelliJ IDEA to
get started Community Edition from JetBrains at
.jetbrains.com/idea/download (Figure 1.1)
Figure: 1.1. Download IntelliJ IDEA Community Edition
Then follow the instructions for your system in the instructions for
:installation and configuration on the JetBrains website

-Jetbrains.com/help/idea/install-and-set-up
. product.html

IntelliJ IDEA, or just IntelliJ, helps you write well-structured


code in Kotlin. In addition, it simplifies the development process by
using
built-in tools for launching, debugging, exploring and refactoring
ring code. Find out why we recommend IntelliJ for writing code in
?Kotlin, see For the Curious: Why Use IntelliJ

Your first Kotlin project


Congratulations, you now have the Kotlin programming language
and powerful environment development for writing it. It remains to
solve the last problem: to learn freely "speak" it. The agenda is to
.create a Kotlin project
Start IntelliJ. The Welcome to IntelliJ IDEA window will open (Figure
.1.2)
Figure: 1.2. Welcome dialog
If you have already run IntelliJ, after installation it may display the(
the last project to open. To return to the welcome window, you
need
). close the project by selecting File → Close Project
Click on Create New Project . IntelliJ will display a new New project
window like
.shown in Fig. 1.3
Figure: 1.3. New project creation window
In the New Project window, select Kotlin on the left and Kotlin / JVM on
.the right , as shown in fig. 1.4
In IntelliJ, you can write code in languages ​other than Kotlin, for
,example Java
Python, Scala and Groovy. Choosing Kotlin / JVM indicates that you
are going to write to Kotlin. Moreover, Kotlin / JVM indicates that you
are going to write code that will run under the Java Virtual Machine.
One of the benefits
Kotlin is all about having a set of tools that allow you to write
code that runs on different operating systems and on different
.platforms
From now on, we'll abbreviate Java Virtual Machine to JVM. This(
abbreviation
viatura is often used in the Java developer community. To learn
more
Figure: 1.4. Creating a Kotlin / JVM project
about programming for the JVM can be found in the section "For the
curious: programming JVM programming ”at the end of the
).chapter
Click Next on the New project window . IntelliJ will display the settings
window of your new project (Fig. 1.5). In the Project name field ,
enter the name of the project "Sandbox". The Project location field will
be filled in automatically. You can leave the path by default or
change it by clicking the ... button to the right of the field. Select
version Java 1.8 from Project SDK dropdown to link your project to
.Java Development Kit (JDK) of the eighth version
Why do I need a JDK to write a Kotlin program? JDK opens
environment
IntelliJ access to JVM and Java tools which are needed for
translation
Kotlin code into bytecode (more on that below). Any version is
,technically fine
starting from the sixth. But as far as I know, at the time of this
writing, JDK 8
.works most stably
If Java 1.8 is not listed in the Project SDK dropdown , it means
,thinks that you still do not have JDK 8 installed. Before proceeding
/ do this: download JDK 8 for your system from oracle.com
.technetwork / java / javase / downloads / jdk8-downloads-2133151.html

Figure: 1.5. Project name

,Install JDK and restart IntelliJ. Repeat the steps described earlier
.to create a new project
. When your settings window looks like fig. 1.5, click Finish
IntelliJ will generate a project called Sandbox and display the
project in standard nominal two-pane view (fig. 1.6). IntelliJ will
create a folder on disk
and a series of subfolders with project files in the path specified in
. the Project location field
The panel on the left displays a window with project tools . The
panel on the right is the moment is empty. This will display the
editor window where you can view and edit the contents of your
Kotlin files. Pay
attention to the window with tools on the left. Click the triangle icon
to the left of the Sandbox project name . A list of files used by the
.in the project as shown in fig. 1.7
The project includes all the source code of the program, as well as
information
See the dependency and configuration information. The project can
be split into one or more modules that are considered subprojects.
Default new

Figure: 1.6. Standard two-pane view


Figure: 1.7. Project view

the project contains only one module, which is more than enough
for your
.the first project
The Sandbox.iml file contains the configuration information of your
only
module. .Idea folder contains files with settings for the whole project
and files
with settings for working with a specific project in the IDE (for
example, a list
files opened in the editor). Leave these automatically generated
.bath files in their original form
The External Libraries catalog contains information about external
libraries from which which project depends. If you expand this
directory, you will see that IntelliJ

automatically added Java 1.8 and KotlinJavaRuntime to the


dependency list
project. (You can learn more about organizing projects in IntelliJ at
). JetBrains: jetbrains.org/intellij/sdk/docs/basics/project_sctructure.html
The src folder is where you will put all the files created for
your Sandbox project. So, let's move on to creating and editing your
.the first Kotlin file
Your first Kotlin file
Right click on the src folder in the project tools window
and in the context menu, first select New and then File / Class (Fig.
.1.8)
Figure: 1.8. Creating a new Kotlin file

In the New Kotlin File / Class dialog box, enter “Hello” in the Name field
, and in the Kind field
.leave File (fig. 1.9)
Figure: 1.9. Naming a file
Click OK . IntelliJ will create a new file src / Hello.kt and display its
contents
in the editor window on the right (Fig. 1.10). The .kt extension
indicates that the file contains
lives the source code in Kotlin language, similar to how the java
,extension says
.that the file contains Java code or .py - Python code

Figure: 1.10. Displaying an empty Hello.kt file in the editor window


You are finally ready to write Kotlin code. Stretch your fingers and
apply
pay. Enter the following code into the Hello.kt editor window . (Recall
that on
throughout the book, the code you must enter will be highlighted
).bold

Listing 1.1. "Hello, world!" on Kotlin (Hello.kt)

{ fun main (args: Array <String>)


println ("Hello, world!")
}

The code you write may look strange. Don't despair - towards the
end
reading and writing in Kotlin will come naturally to you. While
.that it is enough to understand the code at a superficial level
The code in Listing 1.1 creates a new function . A function is a
group of instructions options that can be performed later. You will
.learn more about the functions
.details in chapter 4
This particular function - main - has a special meaning in Kotlin.
Main function
defines the starting point of the program. This place is called the
; entry point
,so that the Sandbox project (or any other program) can be started
an entry point must be created in it. All projects in this book
. start from the main function
Your main function contains one instruction (sometimes the
instructions are called operators ): println ("Hello, world!") . println () is
also a function
it, built into the Kotlin standard library . After starting the program
will execute the println ("Hello, world!") method , and IntelliJ will print
,the string
.specified in parentheses (without quotes, that is, just Hello, world! )
Running your file in Kotlin
language
When you finish entering the code from Listing 1.1, IntelliJ displays
a green
an arrow, known as "Program Start", to the left of the first line
If the icon does not appear or you see a red line under( .)fig. 1.11(
the name
file in a tab or somewhere in the code that you entered, it means
that
there is a mistake in the code. Double-check the entered code: it
must match
with the code in Listing 1.1. However, if you see the red-blue Kotlin
).K flag, it is the same as Launching a Program
It's time for the program to come alive and greet the world. Click
the button
launch. In the menu that appears, select Run 'HelloKt' (Figure 1.12).
This will prompt IntelliJ, what do you want to see the program in
.action
Once launched, IntelliJ will execute the code inside the curly braces
( {} ), line by string and exits. Also at the bottom there will be two
new instrumental
.ny windows

Figure: 1.11. Program start button


Another Random Scribd Document
with Unrelated Content
The Project Gutenberg eBook of The Jewish religion
This ebook is for the use of anyone anywhere in the United
States and most other parts of the world at no cost and with
almost no restrictions whatsoever. You may copy it, give it away
or re-use it under the terms of the Project Gutenberg License
included with this ebook or online at www.gutenberg.org. If you
are not located in the United States, you will have to check the
laws of the country where you are located before using this
eBook.

Title: The Jewish religion

Author: M. Friedländer

Release date: March 3, 2024 [eBook #73092]

Language: English

Original publication: London: P. Vallentine & Son, 1900

Credits: Jeroen Hellingman and the Online Distributed


Proofreading Team at https://www.pgdp.net for Project
Gutenberg (This file was produced from images
generously made available by The Internet
Archive/American Libraries.)

*** START OF THE PROJECT GUTENBERG EBOOK THE JEWISH


RELIGION ***
[Contents]

[Contents]

THE
JEWISH RELIGION.

[Contents]
THE
JEWISH RELIGION.

BY M. FRIEDLÄNDER.

SECOND EDITION,
REVISED AND ENLARGED.
LONDON:
P. VALLENTINE & SON,
7, NORTH CRESCENT, TOTTENHAM
COURT ROAD, W.C.
AND 33, DUKE STREET, ALDGATE, E.C.
1900.

[v]

[Contents]
PREFACE.

In presenting this volume to the public the author does not claim
much originality. He merely desires to reproduce the religious
principles which were sown into his heart by his parents, ‫‏ז״ל‬‎, and
cultivated by the great teachers of Israel—the Prophets, the Soferim,
and their successors—in order that the blessing which he himself has
always derived from these principles may also be enjoyed by his
brethren. The original sources of religious knowledge, viz., the
Scriptures and Post-Biblical Jewish Literature, are of course
accessible to all, and every one may sit at the feet of our great
teachers and listen to their instruction. But there are many who are
in need of assistance, who require the aid of an interpreter. The
present volume is intended to render that assistance and to serve as
such interpreter. The author therefore addresses himself to his
brethren, especially to his disciples, in the words of an ancient
teacher of the Mishnah (Aboth v. 25), “Turn it, and turn it over
again;” and if he cannot add also “for everything is in it,” he hopes
[vi]that that which is in it will be found useful to those who seek
religious knowledge, and that it will prove an incentive to many “to
learn and teach, to heed and do, and to fulfil in love all the words of
instruction in the Divine Law.”

To a great extent this work owes its origin to the warm interest
which the late Mr. Jacob A. Franklin, ‫‏ע״ה‬‎, took in all matters
connected with Judaism. He repeatedly urged upon the author the
necessity of publishing a book on the Jewish Religion. A plan was
suggested, discussed, and finally adopted; but the progress of the
work was slow on account of other literary engagements of the
author. Although Mr. Franklin departed from our midst long before it
was completed, his philanthropy, which survived him, has a share in
its completion, the book being printed at the expense of the Jacob
A. Franklin Trust Fund for the advancement of Judaism. In
recognition of these facts the author dedicates this work— [vii]

In Piety,

TO THE
MEMORY OF HIS LATE FRIEND,

‫‏ר׳ עקיבה בן החבר ר׳ אברהם ז׳ל‬‎

JACOB A. FRANKLIN, O.B.M.


AND
OF HIS BELOVED LATE GRANDCHILDREN:

AZRIEL & URIEL GASTER.

‫‏עזריאל ואוריאל גאסטער‬‎

‫‏ת׳נ׳צ׳ב׳ה‬‎[viii]

In conclusion, the author begs to thank the Rev. S. Singer for his
assistance and his many valuable suggestions while the book was
passing through the press

M. FRIEDLÄNDER.

Jews’ College, 3 Iyar 5651.


[Contents]
PREFACE TO THE SECOND EDITION.

The first edition being exhausted a second edition has been


prepared. There is no cause for any change in the body of the book.
Religion, both “Glaubenslehre” and “Pflichtenlehre,” are given as
objectively as possible, and the most rigid examination of all that is
taught in “The Jewish Religion,” discovered no misstatement. A few
unimportant errors, which according to the Psalmist (Ps. xix) are
excusable, are rectified in the list of Errata. Questions concerning
religious principles which have arisen in the Community since the
publication have been foreseen and dealt with according to Law and
Tradition. A few notes are added in the second edition, where further
elucidations seemed necessary. There is also appended the
bibliography of text-books of Jewish Religion, an abstract of a paper
on Religious Education, read before the Jews’ College Literary
Society, and the prayer which in the Spanish and Portuguese
Synagogues is offered up by the Barmitzvah when called to the Law.
The latter practice is worthy of imitation.

M. F.

London, Adar I., 5660. [ix]

[Contents]
CONTENTS.

PAGE
Introduction 1–18
What is Judaism? 2

OUR CREED.

Faith as commended in Bible and Tradition 5


Faith according to Saadiah 9
Ibn Gabirol
,, ,, ,, 11
Dunash ben Tamim, Bachya b. Joseph
,, ,, ,, 12
Shem-tob; Abraham b. David; Jehudah
,, ,, ,,
hallevi 13
Ibn Ezra; Maimonides; Joseph Albo
,, ,, ,, 14
Eliah del Medigo
,, ,, ,, 15
Moses Mendelssohn
,, ,, ,, 16
The Thirteen Principles of Faith 19
First Group of Principles—Existence of God 22
Natural Religion 22
Polytheism 25
Pantheism 26
Atheism 27
Deism; Theism 29
The First Principle: God, the Creator and Ruler of the
Universe 30
Natural Laws and Miracles 31
Evolution and Creation 33
Principle II.—Unity of God 38
III.
,, 41
Anthropomorphism in the Bible 41
Principle IV. 43
V. [x]
,, 44
Various Attributes of God 41
Second Group of Principles—Revelation 46
General Remarks—Early Revelations 46
Prophet 49
Text of Prophecies 53
Massorah 55
Names and Authors of the Books of the Bible 55
Pentateuch 57
Earlier Prophets 62
Latter Prophets 66
Isaiah 66
Jeremiah 70
Ezekiel 75
Minor Prophets 78
Hagiographa 87
Psalms 87
Proverbs 96
Job 108
The Song of Solomon 112
Ruth; Lamentations 113
Ecclesiastes 114
Esther; Daniel 116
Ezra; Nehemiah 125
Chronicles 126
Apocrypha 127
The Book of Wisdom 127
The Wisdom of Jesus, Son of Sirach 128
Baruch 129
Tobit; Judith 130
The Books of the Maccabees 131
Principle VI.—Truth of the Prophecies 131
VII.—Distinction of Moses from other Prophets
,, 133
VIII.—Authenticity of the Torah
,, 134
The Oral Law 136
Principle IX.—Immutability of the Torah 139
Third Group of Principles—Reward and Punishment 142
Divine Justice and Man’s Free-will 142
Principle X.—God’s Omniscience 148
XI.—Reward and Punishment [xi]
,, 150
Principle XII.—Messiah 155
XIII.—Resurrection—Future Life
,, 163
Notes on the Number of Principles 169
On Principle I. 174
Creation according to Maimonides 174
Saadiah
,, ,, ,, 177
Bible and Science 178
On Principle V.—Efficacy of Prayer 183
Revelation
,, 190
Principle VI.
,, 192
Revelation according to Saadiah 192
Jehudah hallevi
,, ,, ,, 194
Ibn Ezra
,, ,, ,, 197
Maimonides
,, ,, ,, 197
Albo
,, ,, ,, 201
On Principle VII. 201
VIII.
,, ,, 202
Variæ Lectiones, Tikkun Soferim, Ittur Soferim
,, 203
Al-tikre, Biblical Quotations in Talmud and Midrash
,, 204
Bible Criticism
,, 205
the Pentateuch
,, 205
Explanation of 2 Kings xxii. 8 sqq. 207
Abraham ibn Ezra’s View on the Integrity of the Pentateuch 210
Authenticity of the Book of the Prophet Isaiah 212
Authenticity of the Book of Daniel 214
On Principle IX. 215
Explanation of Jer. xxxi. 31–33 216
some Talmudical Passages
,, ,, 216
The Immutability of the Torah according to Maimonides 217
The Immutability of the Torah according to Jehudah hallevi 218
The Immutability of the Torah according to Albo and R.
Abraham b. David 219
On Principle X. 220
XI.
,, ,, 221
Eternal Punishment
,, 223
Vicarious Atonement
,, 224
Principle XII.
,, 225
Maimonides on Messiah, Jesus, and Mohammed 226
Principle XIII. 231

[xii]

OUR DUTIES.

On Religious Duties in General 233


Classification of the Divine Precepts 239
Object of the Divine Law 242
I. The Ten Commandments 247–272
Notes on the Ten Commandments 266–272
Different Opinions on the Division of the
Commandments 266
Ibn Ezra on Exod. xx. 2 269
Abarbanel and R. S. Hirsch on the Ten
Commandments 270
Parallels to the Decalogue 272
II. General Moral Principles 272–328
Duties towards God 273–291
(a.) Duties of the Heart 273–278
Fear and Love of God 273
Gratitude toward Him 275
Reverence for His Name 275
Obedience to His Will 276
Faith and Confidence in His Goodness 277
Resignation to His Will 277
(b.) Duties with reference to Speech 278–288
Prayer 280
Study of His Word 285
(c.) Duties with reference to Action 288–291
Sanctification of God’s Name 289
Imitation of His Ways 290
Duties towards our Fellow-creatures 292–319
General Principles 292
Duties in reference to the Life and the Property
of our Fellow-man 292
Prohibition of Interest and Usury 294
Duties in reference to our Fellow-men’s Honour
and Well-being 298
Charity, ‫‏גמלות חסד‬‎and ‫‏צדקה‬‎ 302
Special Duties 305–318
Children and Parents 305
Friends 306
Husband and Wife 310
Fellow-citizens 310
Fellow-members of a Community [xiii] 312
Duties towards Members of another Community 312
Employers and Employed 313
Superiors and Inferiors 313
Teacher and Pupil; Master and Servant; Rich
and Poor 314
Duties towards the Old, Magistrates, and all to
whom Honour is due 317
Kindness to Animals 318
Duties to Ourselves 319–328
III. Signs as Outward Reminders of God and His Will 328–338
Tsitsith 329
Tefillin 331
Mezuzah 335
Circumcision 336
Notes 336
IV. Sabbath, Festivals, and Fasts 339–413
On Sabbath and Festivals in General 339–360
1. ‫‏זכור‬‎“Remember” 340–349
Kiddush and Habhdalah 340
Lessons from the Pentateuch and the Prophets 345
2. ‫‏שמור‬‎“Take Heed” 349–353
Work Forbidden 349
3. ‫‏ענג‬‎“Delight” 353–355
Sabbath and Festivals Days of Cheerfulness 353
4. ‫‏כבוד‬‎“Honour” 355–358
Sabbath and Festival Bread and Lights 355
Notes 358
The Jewish Calendar 360
Notes 367
The Festivals 368–409
The Three Festivals ‫‏שלש רגלים‬‎ 369–400
The Four Distinguished Sabbaths 369
Passover 372–392
Seder-evening 379
Counting of the Omer 389
The Days of the Counting of the Omer 392
The Feast of Weeks 393–394
The Feast of Tabernacles 395–400
Solemn Days ‫‏ימים נוראים‬‎ 400–409
New-year [xiv] 402
Day of Atonement 405
Historical Feasts and Fasts 409–413
Chanuccah 409
Purim 411
The Four Fasts 412
Optional Fasts 413
V. Divine Worship 413–455
Beginnings of Divine Worship 413
Sacrifices 414
Prayer 418–455
Devotion 419
Minhag or Custom 419
Prayer in Hebrew 420
Efficacy of Prayer 422
Synagogue 423
Instrumental Music in Synagogue 427
The Ritual, in Talmud and Midrash 429
Prayers at Fixed Times 435
Shema, ‫‏שמע‬‎ 436
Amidah or Tefillah 437
Abridged Forms of the Amidah 439
Other Constituent Elements of the Service 439
Night-prayer 440
Public Service 441
Kaddish 441
Kedushah 442
Repetition of Amidah 442
Priests’ Benediction 442
The Reading of the Law 442
Occasional Prayers; Benedictions; Grace 442
Notes on Customs in Synagogue 444
Temporary Substitutes for the Service 446
Repetition of the Amidah 446
Kedushah; Kaddish 447
Sermons and Lectures 448
Special Prayer-Meetings 449
Reform of the Ritual 449
Congregations and their Religious Guide 454
VI. The Dietary Laws [xv] 455–466
Their Object 455
‫‏ערלה‬‎Fruit of Trees in the First Three Years 457
‫‏חדש‬‎, ‫‏כלאים‬‎, ‫‏שעטנז‬‎ 457
Meaning of ‫‏חקות‬‎ 458
The Killing of Animals for Food 459
Prohibition of Blood 459
Trefah 459
Clean and Unclean Animals 459
Forbidden Fat 461
The Sinew that Shrank 461
Meat and Milk 461
Notes.—Explanation of Gen. ix. 4—Seven
Noachide Precepts 462
On Shechitah 463
How to Kasher the Meat 463
Explanation of Num. xi. 22 and Lev. xvii. 13 464
On Clean and Unclean Birds 465
Meat and Milk 465
Honey 466
Wine of Libation 466
VII. Jewish Life 467–496
Guiding Principles in Jewish Life 467
Torah and Abodah; Beth-hammidrash and
Synagogue 469
Charity 469
Jewish Women 470
The Days of the Week 473
Anticipation of Sabbath, Feast, and Fast 474
Friday Evening.—Sabbath and Festivals 475
New-moon and Full-moon 476
Important Moments in the Life of the Jew 476–494
Birth.—Initiation of the Male Child into the
Covenant of Abraham 477
Redemption of the First-born 478
Thanksgiving of the Mother after Confinement 479
‫‏ברכת הגומל‬‎ 479
Education 479
Bar-mitsvah 481
Choice of Vocation 482
Marriage 483
Divorce [xvi] 487
Obligatory Marriage (‫‏יבום‬‎) and Obligatory
Divorce (‫‏הליצה‬‎) 488
Death and Mourning 489
Regard for the Memory of the Deceased 494
Notes on Customs in Connection with the Burial
Rites 496

Appendices:—

I. The Thirteen Principles in Hebrew 497–498


II. The Jewish Calendar 498–501
III. Religious Education 501*–504*
IV. Prayer for Barmitzvah 505*–506*
V. Bibliography 507*–510*
I. Index of Quotations from Bible and Post-Biblical
Literature 502–512
II. General Index 513–520
III. Index of Names 521–523
IV. Index of Hebrew Terms 524–528
Errata 529–530

[1]
[Contents]
THE JEWISH RELIGION.
INTRODUCTION.
“Man is the most privileged of creatures; he has been made in the
image of God. His privilege is still further enhanced by the fact that
he has been made aware of his distinction” (Aboth iii. 14). There is
in man a consciousness or feeling of a certain relation between him
and a superior Being, on whose Will his own existence depends. This
consciousness is the basis of religion, but is not religion itself. It is
the influence which this feeling exercises over man’s actions and
conduct in life that forms the essence of religion. When man begins
to feel that he is responsible for his actions to a higher Being, and
forms his actions in harmony with this feeling, he may be called
religious. Two elements must therefore be distinguished in religion:
the notion of man’s dependence on and responsibility to a superior
Being, and the influence of this notion on his actions: religious belief
and religious practice, or faith and duty. Religious belief or faith, in
its most simple and most general form, may be said to be common
almost to all mankind; and in the great variety of faiths, produced by
[2]various circumstances and experiences, this simple idea may easily
be detected as the fundamental principle of all of them. The same
can be said with regard to religious practice. There are certain
fundamental principles of duty which are recognised and adopted by
the most diverse religious sects; they form, as it were, the common
stem from which a large number of branches spring forth in all
directions. These branches diverge more and more the larger they
grow and the more numerous they become.

Judaism is one of these various religions. It has been the source of


most of the religions of the civilised world, and is destined to
become, in its simplest principles, the universal religion.
What is Judaism? or what does Judaism teach its adherents to
believe, and what does it teach them to do? The answers to these
two questions form the main subject of every book on our holy
religion. The answer to the first question must include our doctrine
about God, His attributes, His relation to the material world, and
especially to man; the mission of man, his hopes and fears. The
answer to the second question must include our duties toward God,
toward our fellow-men, and toward ourselves. Both answers must be
based on that which we are taught in the Holy Writings, and
especially in the Torah. Recourse may be had to philosophic
speculation, to which, indeed, the first question peculiarly invites,
but the result must be rectified by the teaching of the Torah.

In accordance with the maxim, “The secret things belong to the Lord
our God; but those things which are revealed belong unto us and to
our children for [3]ever: that we may do all the words of this Law,”
abstruse metaphysical disquisitions about the essence and the
attributes of the Divine Being will be avoided in the present work, as
also every attempt at proving, philosophically or mathematically,
truths which have been revealed unto us in a supernatural way. 1 But
the simple truths taught in the Holy Writings and explained by our
sages will be expounded, the different opinions about them will be
examined, and it will be shown that these truths are not
contradicted by common sense or by the results of scientific
research.

The second question, however, What does Judaism teach us to do?


refers to “the things which are revealed,” and must be treated more
fully. Care will be taken, as far as possible, that nothing be omitted
that is required for the right understanding and the correct estimate
of our religious duties. [4]
Religion therefore includes two elements: faith and practice. In
religious life, as well as in the teaching of religion, both elements are
equally essential; faith without religious practice does not suffice,
nor the latter without faith. We are accustomed to look upon certain
dogmas as fundamental, and certain practices as essential, and are
therefore prone to renounce beliefs which are not fundamental in
our eyes, and to abandon such religious practice as seems to us less
essential. Hence the frequent inquiry as to what is the minimum of
belief, and what the minimum degree of conformity to the Law, that
Judaism demands. But in reality there can be no compromise in
religion, whether in matters of faith or of practice. Convinced of a
certain number of truths, it is impossible for us to abandon any of
them without being false to ourselves; being convinced of the
binding character of certain religious commands and prohibitions, it
would be perverse to pronounce at the same time part of them as
superfluous. Judaism is the adherence to the truths taught in the
Holy Law, and the faithful obedience to its precepts.

The principal Hebrew equivalents for the modern term “Religion,”


‫‏תורה‬‎and ‫‏אמונה‬‎, confirm this view. In the Bible ‫‏תורה‬‎signifies
“instruction,” and is applied to the teaching of religions truth, as well
as to that of religious precepts. The same is the case with the
second term ‫‏אמונה‬‎which signifies “firmness,” “perseverance,” or
“permanence,” and is used of “consistency” in faith as well as of
conscientiousness in the practice of the Divine ordinances. 2 [5]

1 When our great theologians, Saadiah, Bachya, Maimonides, Albo, &c.,


considered it necessary to write long and abstruse metaphysical essays in order
to firmly establish certain truths, it was done rather for the purpose of combating
the views of opponent theologians than for the instruction of the multitude, and it
may fairly be said that Maimonides has done far greater service to his brethren by
the composition of a systematic code of laws than by his philosophical “Guide.”
The former, the Mishneh-Torah, never fails to enlighten those who seek in it
enlightenment with regard to some religious duty, whilst the “Guide” would
scarcely relieve anyone of his perplexities in matters of religious belief. There is a
saying in the Talmud Jerus. (Chagigah, ch. i.), “Would that they had forgotten me,
and kept my commandments!” or, in other words, “Theologians would do better if
they were less eager to investigate into the essence of God and His attributes, and
were more anxious to study and to do God’s commandments.” Instead of devoting
their chief attention to the knowledge and the practice of the Law, they waste
their energy and their time in attempts to solve problems to which the human
mind is unequal (S. Plessner, Religions-Unterricht, p. xxxviii.). ↑
2 Post-biblical authors frequently employ the term ‫‏אמונה‬‎in the sense of religious
belief, and ‫‏תורה‬‎in the sense of religious duties; the equivalent for religion is
‫‏דת‬‎. ↑
[Contents]
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

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

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like