100% found this document useful (1 vote)
27 views

(eBook PDF) Introduction to Java Programming, Brief Version, Global Edition 11th Edition 2024 Scribd Download

The document provides links to various Java programming eBooks available for download on ebookluna.com, including titles like 'Introduction to Java Programming' and 'Java: An Introduction to Problem Solving and Programming.' It outlines the structure of the book, covering fundamental programming concepts, object-oriented programming, and GUI programming with JavaFX. Additionally, it mentions resources for students and instructors, including online practice tools and video notes.

Uploaded by

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

(eBook PDF) Introduction to Java Programming, Brief Version, Global Edition 11th Edition 2024 Scribd Download

The document provides links to various Java programming eBooks available for download on ebookluna.com, including titles like 'Introduction to Java Programming' and 'Java: An Introduction to Problem Solving and Programming.' It outlines the structure of the book, covering fundamental programming concepts, object-oriented programming, and GUI programming with JavaFX. Additionally, it mentions resources for students and instructors, including online practice tools and video notes.

Uploaded by

sanuseremice
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/ 48

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

com

(eBook PDF) Introduction to Java Programming,


Brief Version, Global Edition 11th Edition

https://ebookluna.com/product/ebook-pdf-introduction-to-
java-programming-brief-version-global-edition-11th-edition/

OR CLICK HERE

DOWLOAD NOW

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


Instant digital products (PDF, ePub, MOBI) ready for you
Download now and discover formats that fit your needs...

(eBook PDF) Introduction to Java Programming and Data


Structures, Comprehensive Version, 11th Global Edition

https://ebookluna.com/product/ebook-pdf-introduction-to-java-
programming-and-data-structures-comprehensive-version-11th-global-
edition/
ebookluna.com

Introduction to Java Programming, Comprehensive Version


10th edition- eBook PDF

https://ebookluna.com/download/introduction-to-java-programming-
comprehensive-version-ebook-pdf/

ebookluna.com

(eBook PDF) Introduction to JAVA Programming and Data


Structures Comprehensive Version 11

https://ebookluna.com/product/ebook-pdf-introduction-to-java-
programming-and-data-structures-comprehensive-version-11/

ebookluna.com

(eBook PDF) Java: An Introduction to Problem Solving and


Programming 7th Edition

https://ebookluna.com/product/ebook-pdf-java-an-introduction-to-
problem-solving-and-programming-7th-edition/

ebookluna.com
(eBook PDF) Java: An Introduction to Problem Solving and
Programming 8th Edition

https://ebookluna.com/product/ebook-pdf-java-an-introduction-to-
problem-solving-and-programming-8th-edition/

ebookluna.com

(eBook PDF) Introduction to Programming with Java: A


Problem Solving Approach 3rd Edition

https://ebookluna.com/product/ebook-pdf-introduction-to-programming-
with-java-a-problem-solving-approach-3rd-edition/

ebookluna.com

(eBook PDF) Java How to Program, Late Objects Global


Edition 11th Edition

https://ebookluna.com/product/ebook-pdf-java-how-to-program-late-
objects-global-edition-11th-edition/

ebookluna.com

(eBook PDF) Calculus with Applications, Brief Version 11th


Edition

https://ebookluna.com/product/ebook-pdf-calculus-with-applications-
brief-version-11th-edition/

ebookluna.com

Theatre, Brief Version 11th Edition Robert Cohen - eBook


PDF

https://ebookluna.com/download/theatre-brief-version-ebook-pdf/

ebookluna.com
6 Preface
Part I: Fundamentals of Part II: Object-Oriented Part III: GUI Programming
Programming Programming
Chapter 1 Introduction to Chapter 9 Objects and Classes Chapter 14 JavaFX Basics
Computers, Programs, and
Java
Chapter 10 Thinking in Objects Chapter 15 Event-Driven
Programming and
Chapter 2 Elementary Animations
Chapter 11 Inheritance and
Programming
Polymorphism
Chapter 16 JavaFX Controls
Chapter 3 Selections and Multimedia
Chapter 12 Exception
Handling and Text I/O
Chapter 4 Mathematical
Functions, Characters, Chapter 13 Abstract Classes
and Strings and Interfaces

Chapter 5 Loops Chapter 17 Binary I/O

Chapter 6 Methods

Chapter 7 Single-Dimensional
Arrays

Chapter 8 Multidimensional
Arrays

Chapter 18 Recursion

Organization of the Book


The chapters in this brief version can be grouped into three parts that, taken together, form a
solid introduction to Java programming. Because knowledge is cumulative, the early chapters
provide the conceptual basis for understanding programming and guide students through simple
examples and exercises; subsequent chapters progressively present Java programming in detail,
culminating with the development of comprehensive Java applications. The appendixes contain
a mixed bag of topics, including an introduction to number systems, bitwise operations, regular
expressions, and enumerated types.

Part I: Fundamentals of Programming (Chapters 1–8, 18)


The first part of the book is a stepping stone, preparing you to embark on the journey of learning
Java. You will begin to learn about Java (Chapter 1) and fundamental programming t­echniques
with primitive data types, variables, constants, assignments, expressions, and operators (Chapter
2), selection statements (Chapter 3), mathematical functions, characters, and strings (Chapter 4),
loops (Chapter 5), methods (Chapter 6), and arrays (Chapters 7–8). After Chapter 7, you can jump
to Chapter 18 to learn how to write recursive methods for solving inherently recursive problems.

Part II: Object-Oriented Programming (Chapters 9–13, and 17)


This part introduces object-oriented programming. Java is an object-oriented programming
language that uses abstraction, encapsulation, inheritance, and polymorphism to provide
Preface  7
great flexibility, modularity, and reusability in developing software. You will learn program-
ming with objects and classes (Chapters 9–10), class inheritance (Chapter 11), polymorphism
(­Chapter 11), exception handling (Chapter 12), abstract classes (Chapter 13), and interfaces
(Chapter 13). Text I/O is introduced in Chapter 12 and binary I/O is discussed in Chapter 17.

Part III: GUI Programming (Chapters 14–16)


JavaFX is a new framework for developing Java GUI programs. It is not only useful for
developing GUI programs, but also an excellent pedagogical tool for learning object-oriented
programming. This part introduces Java GUI programming using JavaFX in Chapters 14–16.
Major topics include GUI basics (Chapter 14), container panes (Chapter 14), drawing shapes
(Chapter 14), event-driven programming (Chapter 15), animations (Chapter 15), and GUI con-
trols (Chapter 16), and playing audio and video (Chapter 16). You will learn the architecture
of JavaFX GUI programming and use the controls, shapes, panes, image, and video to develop
useful applications.

Appendixes
This part of the book covers a mixed bag of topics. Appendix A lists Java keywords.
­Appendix B gives tables of ASCII characters and their associated codes in decimal and in
hex. Appendix C shows the operator precedence. Appendix D summarizes Java modifiers and
their usage. Appendix E discusses special floating-point values. Appendix F introduces num-
ber systems and conversions among binary, decimal, and hex numbers. Finally, Appendix G
introduces bitwise operations. Appendix H introduces regular expressions. Appendix I covers
enumerated types.

Java Development Tools


You can use a text editor, such as the Windows Notepad or WordPad, to create Java programs
and to compile and run the programs from the command window. You can also use a Java
development tool, such as NetBeans or Eclipse. These tools support an integrated develop-
ment environment (IDE) for developing Java programs quickly. Editing, compiling, building,
executing, and debugging programs are integrated in one graphical user interface. Using these
tools effectively can greatly increase your programming productivity. NetBeans and Eclipse
are easy to use if you follow the tutorials. Tutorials on NetBeans and Eclipse can be found in IDE tutorials
the supplements on the Companion Website at www.pearsonglobaleditions.com/Liang.

Student Resources
The Companion Website (www.pearsonglobaleditions.com/Liang) contains the following
resources:
■■ Answers to CheckPoint questions
■■ Solutions to majority of even-numbered programming exercises
■■ Source code for the examples in the book
■■ Interactive quiz (organized by sections for each chapter)
■■ Supplements
■■ Debugging tips
■■ Video notes
■■ Algorithm animations
8 Preface

Supplements
The text covers the essential subjects. The supplements extend the text to introduce additional
topics that might be of interest to readers. The supplements are available from the Companion
Website.

Instructor Resources
The Companion Website, accessible from www.pearsonglobaleditions.com/Liang, c­ ontains the
following resources:
■■ Microsoft PowerPoint slides with interactive buttons to view full-color, syntax-highlighted
source code and to run programs without leaving the slides.
■■ Solutions to a majority of odd-numbered programming exercises.
■■ More than 200 additional programming exercises and 300 quizzes organized by ­chapters.
These exercises and quizzes are available only to the instructors. Solutions to these
­exercises and quizzes are provided.
■■ Web-based quiz generator. (Instructors can choose chapters to generate quizzes from a
large database of more than two thousand questions.)
■■ Sample exams. Most exams have four parts:
■■ Multiple-choice questions or short-answer questions
■■ Correct programming errors
■■ Trace programs
■■ Write programs
■■ Sample exams with ABET course assessment.
■■ Projects. In general, each project gives a description and asks students to analyze, design,
and implement the project.
Some readers have requested the materials from the Instructor Resource Center. Please
­understand that these are for instructors only. Such requests will not be answered.

Online Practice and Assessment


with MyProgrammingLab
MyProgrammingLab helps students fully grasp the logic, semantics, and syntax of program-
ming. Through practice exercises and immediate, personalized feedback, MyProgrammingLab
improves the programming competence of beginning students who often struggle with the
basic concepts and paradigms of popular high-level programming languages.
A self-study and homework tool, a MyProgrammingLab course consists of hundreds of
small practice problems organized around the structure of this textbook. For students, the sys-
tem automatically detects errors in the logic and syntax of their code submissions and offers
targeted hints that enable students to figure out what went wrong—and why. For instructors,
a comprehensive gradebook tracks correct and incorrect answers and stores the code inputted
by students for review.
Preface  9
MyProgrammingLab is offered to users of this book in partnership with Turing’s Craft, the
makers of the CodeLab interactive programming exercise system. For a full demonstration,
to see feedback from instructors and students, or to get started using MyProgrammingLab in
your course, visit www.myprogramminglab.com.

Video Notes
We are excited about the new Video Notes feature that is found in this new edition. These VideoNote

videos provide additional help by presenting examples of key topics and showing how
to solve problems completely, from design through coding. Video Notes are available from
www.pearsonglobaleditions.com/Liang.

Algorithm Animations
We have provided numerous animations for algorithms. These are valuable pedagogical tools Animation
to demonstrate how algorithms work. Algorithm animations can be accessed from the Com-
panion Website.
10 Preface

Acknowledgments
I would like to thank Armstrong State University for enabling me to teach what I write and for
supporting me in writing what I teach. Teaching is the source of inspiration for continuing to
improve the book. I am grateful to the instructors and students who have offered comments,
suggestions, bug reports, and praise.
This book has been greatly enhanced thanks to outstanding reviews for this and previous
editions. The reviewers are: Elizabeth Adams (James Madison University), Syed Ahmed (North
Georgia College and State University), Omar Aldawud (Illinois Institute of Technology), Stefan
Andrei (Lamar University), Yang Ang (University of Wollongong, Australia), Kevin Bierre
(Rochester Institute of Technology), Aaron Braskin (Mira Costa High School), David Champion
(DeVry Institute), James Chegwidden (Tarrant County College), Anup Dargar (University of
North Dakota), Daryl Detrick (Warren Hills Regional High School), Charles Dierbach (Towson
University), Frank Ducrest (University of Louisiana at Lafayette), Erica Eddy (University of
Wisconsin at Parkside), Summer Ehresman (Center Grove High School), Deena Engel (New
York University), Henry A. Etlinger (Rochester Institute of Technology), James Ten Eyck
(Marist College), Myers Foreman (Lamar University), Olac Fuentes (University of Texas at
El Paso), Edward F. Gehringer (North Carolina State University), Harold Grossman (Clemson
University), Barbara Guillot (Louisiana State University), Stuart Hansen (University of Wis-
consin, Parkside), Dan Harvey (Southern Oregon University), Ron Hofman (Red River College,
Canada), Stephen Hughes (Roanoke College), Vladan Jovanovic (Georgia Southern University),
Deborah Kabura Kariuki (Stony Point High School), Edwin Kay (Lehigh University), Larry
King (University of Texas at Dallas), Nana Kofi (Langara College, Canada), George Koutsogi-
annakis (Illinois Institute of Technology), Roger Kraft (Purdue University at Calumet), Norman
Krumpe (Miami University), Hong Lin (DeVry Institute), Dan Lipsa (Armstrong State Univer-
sity), James Madison (Rensselaer Polytechnic Institute), Frank Malinowski (Darton College),
Tim Margush (University of Akron), Debbie Masada (Sun Microsystems), Blayne Mayfield
(Oklahoma State University), John McGrath (J.P. McGrath Consulting), Hugh McGuire (Grand
Valley State), Shyamal Mitra (University of Texas at Austin), Michel Mitri (James Madison
University), Kenrick Mock (University of Alaska Anchorage), Frank Murgolo (California State
University, Long Beach), Jun Ni (University of Iowa), Benjamin Nystuen (University of Colo-
rado at Colorado Springs), Maureen Opkins (CA State University, Long Beach), Gavin Osborne
(University of Saskatchewan), Kevin Parker (Idaho State University), Dale Parson (Kutztown
University), Mark Pendergast (Florida Gulf Coast University), Richard Povinelli (Marquette
University), Roger Priebe (University of Texas at Austin), Mary Ann Pumphrey (De Anza Junior
College), Pat Roth (Southern Polytechnic State University), Amr Sabry (Indiana University),
Ben Setzer (Kennesaw State University), Carolyn Schauble (Colorado State University), David
Scuse (University of Manitoba), Ashraf Shirani (San Jose State University), Daniel Spiegel
(Kutztown University), Joslyn A. Smith (Florida Atlantic University), Lixin Tao (Pace Uni-
versity), Ronald F. Taylor (Wright State University), Russ Tront (Simon Fraser University),
Deborah Trytten (University of Oklahoma), Michael Verdicchio (Citadel), Kent Vidrine (George
Washington University), and Bahram Zartoshty (California State University at Northridge).
It is a great pleasure, honor, and privilege to work with Pearson. I would like to thank Tracy
Johnson and her colleagues Marcia Horton, Demetrius Hall, Yvonne Vannatta, Kristy Alaura,
Carole Snyder, Scott Disanno, Bob Engelhardt, Shylaja Gattupalli, and their colleagues for
organizing, producing, and promoting this project.
As always, I am indebted to my wife, Samantha, for her love, support, and encouragement.
Preface  11

Acknowledgments for the Global Edition


Pearson would like to thank and acknowledge Yvan Maillot (Univresite Haute-Alsace) and
Steven Yuwono (National University of Singapore) for contributing to this Global Edition,
and Arif Ahmed (National Institute of Technology, Silchar), Annette Bieniusa (University
of Kaiserslautern), Shaligram Prajapat (Devi Ahilya Vishwavidyalaya, Indore), and Ram
Gopal Raj (University of Malaya) for reviewing this Global Edition.
CONTENTS
Chapter 1 I ntroduction to Computers,
­Programs, and Java™ 23
1.1 Introduction 24
1.2 What Is a Computer? 24
1.3 Programming Languages 29
1.4 Operating Systems 31
1.5 Java, the World Wide Web, and Beyond 32
1.6 The Java Language Specification, API, JDK,
JRE, and IDE 33
1.7 A Simple Java Program 34
1.8 Creating, Compiling, and Executing a Java Program 37
1.9 Programming Style and Documentation 40
1.10 Programming Errors 42
1.11 Developing Java Programs Using NetBeans 45
1.12 Developing Java Programs Using Eclipse 47

Chapter 2 Elementary Programming 55


2.1 Introduction 56
2.2 Writing a Simple Program 56
2.3 Reading Input from the Console 59
2.4 Identifiers 62
2.5 Variables 62
2.6 Assignment Statements and Assignment Expressions 64
2.7 Named Constants 65
2.8 Naming Conventions 66
2.9 Numeric Data Types and Operations 67
2.10 Numeric Literals 70
2.11 Evaluating Expressions and Operator Precedence 72
2.12 Case Study: Displaying the Current Time 74
2.13 Augmented Assignment Operators 76
2.14 Increment and Decrement Operators 77
2.15 Numeric Type Conversions 79
2.16 Software Development Process 81
2.17 Case Study: Counting Monetary Units 85
2.18 Common Errors and Pitfalls 87

Chapter 3 Selections 97
3.1 Introduction 98
3.2 boolean Data Type 98
3.3 if Statements 100
3.4 Two-Way if-else Statements 102
3.5 Nested if and Multi-Way if-else Statements 103
3.6 Common Errors and Pitfalls 105
3.7 Generating Random Numbers 109
3.8 Case Study: Computing Body Mass Index 111
3.9 Case Study: Computing Taxes 112
3.10 Logical Operators 115
3.11 Case Study: Determining Leap Year 119
3.12 Case Study: Lottery 120
3.13 switch Statements 122
12
Contents  13
3.14 Conditional Operators 125
3.15 Operator Precedence and Associativity 126
3.16 Debugging 128

Chapter 4 Mathematical Functions,


Characters, and Strings 141
4.1 Introduction 142
4.2 Common Mathematical Functions 142
4.3 Character Data Type and Operations 147
4.4 The String Type 152
4.5 Case Studies 161
4.6 Formatting Console Output 167

Chapter 5 Loops 181


5.1 Introduction 182
5.2 The while Loop 182
5.3 Case Study: Guessing Numbers 185
5.4 Loop Design Strategies 188
5.5 Controlling a Loop with User Confirmation or a Sentinel Value 190
5.6 The do-while Loop 192
5.7 The for Loop 195
5.8 Which Loop to Use? 198
5.9 Nested Loops 200
5.10 Minimizing Numeric Errors 202
5.11 Case Studies 204
5.12 Keywords break and continue 208
5.13 Case Study: Checking Palindromes 211
5.14 Case Study: Displaying Prime Numbers 213

Chapter 6 Methods 227


6.1 Introduction 228
6.2 Defining a Method 228
6.3 Calling a Method 230
6.4 void vs. Value-Returning Methods 233
6.5 Passing Parameters by Values 236
6.6 Modularizing Code 239
6.7 Case Study: Converting Hexadecimals to Decimals 241
6.8 Overloading Methods 243
6.9 The Scope of Variables 246
6.10 Case Study: Generating Random Characters 247
6.11 Method Abstraction and Stepwise Refinement 249

Chapter 7 Single-Dimensional Arrays 269


7.1 Introduction 270
7.2 Array Basics 270
7.3 Case Study: Analyzing Numbers 277
7.4 Case Study: Deck of Cards 278
7.5 Copying Arrays 280
7.6 Passing Arrays to Methods 281
7.7 Returning an Array from a Method 284
7.8 Case Study: Counting the Occurrences of Each Letter 285
7.9 Variable-Length Argument Lists 288
7.10 Searching Arrays 289
7.11 Sorting Arrays 293
14 Contents
7.12 The Arrays Class 294
7.13 Command-Line Arguments 296

Chapter 8 Multidimensional Arrays 311


8.1 Introduction 312
8.2 Two-Dimensional Array Basics 312
8.3 Processing Two-Dimensional Arrays 315
8.4 Passing Two-Dimensional Arrays to Methods 317
8.5 Case Study: Grading a Multiple-Choice Test 318
8.6 Case Study: Finding the Closest Pair 320
8.7 Case Study: Sudoku 322
8.8 Multidimensional Arrays 325

Chapter 9 Objects and Classes 345


9.1 Introduction 346
9.2 Defining Classes for Objects 346
9.3 Example: Defining Classes and Creating Objects 348
9.4 Constructing Objects Using Constructors 353
9.5 Accessing Objects via Reference Variables 354
9.6 Using Classes from the Java Library 358
9.7 Static Variables, Constants, and Methods 361
9.8 Visibility Modifiers 366
9.9 Data Field Encapsulation 368
9.10 Passing Objects to Methods 371
9.11 Array of Objects 375
9.12 Immutable Objects and Classes 377
9.13 The Scope of Variables 379
9.14 The this Reference 380

Chapter 10 Object-Oriented Thinking 389


10.1 Introduction 390
10.2 Class Abstraction and Encapsulation 390
10.3 Thinking in Objects 394
10.4 Class Relationships 397
10.5 Case Study: Designing the Course Class 400
10.6 Case Study: Designing a Class for Stacks 402
10.7 Processing Primitive Data Type Values as Objects 404
10.8 Automatic Conversion between Primitive Types
and Wrapper Class Types 407
10.9 The BigInteger and BigDecimal Classes 408
10.10 The String Class 410
10.11 The StringBuilder and StringBuffer Classes 416

Chapter 11 Inheritance and


Polymorphism 433
11.1 Introduction 434
11.2 Superclasses and Subclasses 434
11.3 Using the super Keyword 440
11.4 Overriding Methods 443
11.5 Overriding vs. Overloading 444
11.6 The Object Class and Its toString() Method 446
11.7 Polymorphism 447
11.8 Dynamic Binding 447
11.9 Casting Objects and the instanceof Operator 451
11.10 The Object’s equals Method 455
Contents  15
11.11 The ArrayList Class 456
11.12 Useful Methods for Lists 462
11.13 Case Study: A Custom Stack Class 463
11.14 The protected Data and Methods 464
11.15 Preventing Extending and Overriding 467

Chapter 12 Exception Handling


and Text I/O 475
12.1 Introduction 476
12.2 Exception-Handling Overview 476
12.3 Exception Types 481
12.4 More on Exception Handling 484
12.5 The finally Clause 492
12.6 When to Use Exceptions 493
12.7 Rethrowing Exceptions 494
12.8 Chained Exceptions 495
12.9 Defining Custom Exception Classes 496
12.10 The File Class 499
12.11 File Input and Output 502
12.12 Reading Data from the Web 508
12.13 Case Study: Web Crawler 510

Chapter 13 Abstract Classes and Interfaces 521


13.1 Introduction 522
13.2 Abstract Classes 522
13.3 Case Study: the Abstract Number Class 527
13.4 Case Study: Calendar and GregorianCalendar 529
13.5 Interfaces 532
13.6 The Comparable Interface 535
13.7 The Cloneable Interface 540
13.8 Interfaces vs. Abstract Classes 545
13.9 Case Study: The Rational Class 548
13.10 Class-Design Guidelines 553

Chapter 14 JavaFX Basics 563


14.1 Introduction 564
14.2 JavaFX vs Swing and AWT 564
14.3 The Basic Structure of a JavaFX Program 564
14.4 Panes, Groups, UI Controls, and Shapes 567
14.5 Property Binding 570
14.6 Common Properties and Methods for Nodes 573
14.7 The Color Class 575
14.8 The Font Class 576
14.9 The Image and ImageView Classes 578
14.10 Layout Panes and Groups 580
14.11 Shapes 589
14.12 Case Study: The ClockPane Class 602

Chapter 15 Event-Driven Programming


and Animations 615
15.1 Introduction 616
15.2 Events and Event Sources 618
15.3 Registering Handlers and Handling Events 619
15.4 Inner Classes 623
15.5 Anonymous Inner Class Handlers 624
16 Contents
15.6 Simplifying Event Handling Using Lambda Expressions 627
15.7 Case Study: Loan Calculator 631
15.8 Mouse Events 633
15.9 Key Events 635
15.10 Listeners for Observable Objects 638
15.11 Animation 640
15.12 Case Study: Bouncing Ball 648
15.13 Case Study: US Map 652

Chapter 16 JavaFX UI Controls


and Multimedia 665
16.1 Introduction 666
16.2 Labeled and Label 666
16.3 Button 668
16.4 CheckBox 670
16.5 RadioButton 673
16.6 TextField 676
16.7 TextArea 677
16.8 ComboBox 681
16.9 ListView 684
16.10 ScrollBar 687
16.11 Slider 690
16.12 Case Study: Developing a Tic-Tac-Toe Game 693
16.13 Video and Audio 698
16.14 Case Study: National Flags and Anthems 701

Chapter 17 Binary I/O 713


17.1 Introduction 714
17.2 How Is Text I/O Handled in Java? 714
17.3 Text I/O vs. Binary I/O 715
17.4 Binary I/O Classes 716
17.5 Case Study: Copying Files 726
17.6 Object I/O 728
17.7 Random-Access Files 733

Chapter 18 Recursion 741


18.1 Introduction 742
18.2 Case Study: Computing Factorials 742
18.3 Case Study: Computing Fibonacci
Numbers 745
18.4 Problem Solving Using Recursion 748
18.5 Recursive Helper Methods 750
18.6 Case Study: Finding the Directory Size 753
18.7 Case Study: Tower of Hanoi 755
18.8 Case Study: Fractals 758
18.9 Recursion vs. Iteration 762
18.10 Tail Recursion 762

Appendixes 773
Appendix A Java Keywords 775
Appendix B The ASCII Character Set 776
Contents  17

Appendix C Operator Precedence Chart 778


Appendix D Java Modifiers 780
Appendix E Special Floating-Point Values 782
Appendix F Number Systems 783
Appendix G Bitwise Operations 787
Appendix H Regular Expressions 788
Appendix I Enumerated Types 793

Quick Reference 799


Index 801
This page intentionally left blank
VideoNotes
Locations of VideoNotes
VideoNote
www.pearsonglobaleditions.com/Liang

Chapter 1 Introduction to Computers, Programs, Selection sort 293


and Java™ 23 Command-line arguments 297
Your first Java program 34 Coupon collector’s problem 304
Compile and run a Java program 39 Consecutive four 306
NetBeans brief tutorial 45
Eclipse brief tutorial 47 Chapter 8 Multidimensional Arrays 311
Find the row with the largest sum 316
Chapter 2 Elementary Programming 55 Grade multiple-choice test 318
Obtain input 59 Sudoku 322
Use operators / and % 74 Multiply two matrices 331
Software development Even number of 1s 338
process 81
Compute loan payments 82 Chapter 9 Objects and Classes 345
Compute BMI 94 Define classes and objects 346
Use classes 358
Chapter 3 Selections 97 Static vs. instance 361
Program addition quiz 99 Data field encapsulation 368
Program subtraction quiz 109 The this keyword 380
Use multi-way if-else The Fan class 386
statements 112
Sort three integers 132 Chapter 10 Object-Oriented Thinking 389
Check point location 134 The Loan class 391
The BMI class 394
Chapter 4 Mathematical Functions, Characters, The StackOfIntegers class 402
and Strings 141 Process large numbers 408
Introduce Math functions 142 The String class 410
Introduce strings and objects 152 The MyPoint class 424
Convert hex to decimal 165
Compute great circle distance 173 Chapter 11 Inheritance and Polymorphism 433
Convert hex to binary 176 Geometric class hierarchy 434
Polymorphism and dynamic
Chapter 5 Loops 181 binding demo 448
Use while loop 182 The ArrayList class 456
Guess a number 185 The MyStack class 463
Multiple subtraction quiz 188 New Account class 470
Use do-while loop 192
Minimize numeric errors 202 Chapter 12 Exception Handling and Text I/O 475
Display loan schedule 219 Exception-handling advantages 476
Sum a series 220 Create custom exception classes 496
Write and read data 502
Chapter 6 Methods 227 HexFormatException 515
Define/invoke max method 230
Use void method 233 Chapter 13 Abstract Classes and Interfaces 521
Modularize code 239 Abstract GeometricObject class 522
Stepwise refinement 249 Calendar and Gregorian
Reverse an integer 258 Calendar classes 529
Estimate p 261 The concept of interface 532
Redesign the Rectangle class 558
Chapter 7 Single-Dimensional Arrays 269
Random shuffling 274 Chapter 14 JavaFX Basics 563
Deck of cards 278 Getting started with JavaFX 564

19
Another Random Scribd Document
with Unrelated Content
SERMON VI.
THE RIGHTEOUSNESS OF
FAITH.
ROM. x. 5, 6, 7, 8.

Moses describeth the righteousness which is of


the law, that the man which doeth those
things shall live by them.

But the righteousness which is of faith


speaketh on this wise. Say not in thine
heart, who shall ascend into heaven? That
is, to bring Christ down from above:

Or who shall descend into the deep? That is, to


bring Christ again from the dead.
But what saith it? The word is nigh thee, even
in thy mouth and in thy heart that is the
word of faith, which we preach.

T
1. HE apostle does not here oppose the covenant given by
Moses, to the covenant given by Christ. If we ever imagined
this, it was for want of observing, that the latter, as well as
the former part of these words, were spoken by Moses himself, to
the people of Israel, and that, concerning the covenant which then
was. (Deut. xxx. 11, 12, 14.) But it is the covenant of grace, which
God through Christ hath established with men in all ages, (as well
before, and under the Jewish dispensation, as since God was
manifest in the flesh) which St. Paul here opposes to the covenant of
works, made with Adam while in paradise; but commonly supposed
to be the only covenant which God had made with man, particularly
by those Jews of whom the apostle writes.

2. Of these it was that he so affectionately speaks, in the


beginning of this chapter. My heart’s desire and prayer to God for
Israel is, that they may be saved. For I bear them record, that they
have a zeal for God, but not according to knowledge. For they being
ignorant of God’s righteousness (of the justification that flows from
his mere grace and mercy, freely forgiving our sins through the Son
of his love, through the redemption which is in Jesus) and seeking to
establish their own righteousness, (their own holiness, antecedent to
faith in him that justifieth the ungodly, as the ground of their pardon
and acceptance) have not submitted themselves unto the
righteousness of God, and consequently seek death in the error of
their life.

3. They were ignorant, that Christ is the end of the law for
righteousness to every one that believeth, that by the oblation of
himself once offered, he had put an end to the first law or covenant
(which indeed was not given by God to Moses, but to Adam in his
state of innocence) the strict tenor whereof, without any abatement
was, “Do this and live:” And at the same time purchased for us that
better covenant, “Believe and live;” believe and thou shalt be saved;
now saved both from the guilt and power of sin, and, of
consequence, from the wages of it.

4. And how many are equally ignorant now, even among those
who are called by the name of Christ? How many who have now a
zeal for God, yet have it not according to knowledge: but are still
seeking to establish their own righteousness, as the ground of their
pardon and acceptance; and therefore vehemently refuse, to submit
themselves unto the righteousness of God? Surely my heart’s desire,
and prayer to God for you, brethren, is, that ye may be saved. And
in order to remove this grand stumbling-block out of your way, I will
endeavour to shew, first, What the righteousness is, which is of the
law, and what the righteousness which is of faith; Secondly, The
folly of trusting in the righteousness of the law, and the wisdom of
submitting to that which is of faith.

I. 1. And, first, The righteousness which is of the law, saith, the


man which doth these things, shall live by them. Constantly and
perfectly observe all these things to do them, and then thou shalt
live for ever. This law or covenant (usually called, the covenant of
works) given by God to man in paradise, required an obedience,
perfect in all its parts, entire and wanting nothing, as the condition
of his eternal continuance, in the holiness and happiness wherein he
was created.

2. It required, that man should fulfil all righteousness, inward and


outward, negative and positive: that he should not only abstain from
every idle word, and avoid every evil work, but should keep every
affection, every desire, every thought in obedience to the will of
God. That he should continue holy, as he which had created him was
holy, both in heart and in all manner of conversation: that he should
be pure in heart, even as God is pure; perfect as his Father in
heaven was perfect: that he should love the Lord his God with all his
heart, with all his soul, with all his mind, and with all his strength:
that he should love every soul which God had made, even as God
had loved him: that by this universal benevolence, he should dwell in
God (who is love) and God in him: that he should serve the Lord his
God with all his strength, and in all things singly aim at his glory.

3. These were the things which the righteousness of the law


required, that he who did them might live thereby. But it farther
required, that this entire obedience to God, this inward and outward
holiness, this conformity both of heart and life to his will, should be
perfect in degree. No abatement, no allowance could possibly be
made, for falling short in any degree, as to any jot or tittle, either of
the outward or the inward law. If every commandment relating to
outward things was obeyed, yet that was not sufficient, unless every
one was obeyed with all the strength, in the highest measure, and
most perfect manner. Nor did it answer the demand of this covenant,
to love God with every power and faculty, unless he were loved with
the full capacity of each, with the whole possibility of the soul.

4. One thing more was indispensably required by the


righteousness of the law, namely, that this universal obedience, this
perfect holiness both of heart and life, should be perfectly
uninterrupted also, should continue without any intermission, from
the moment wherein God created man, and breathed into his
nostrils the breath of life, until the days of his trial should be ended,
and he should be confirmed in life everlasting.

5. The righteousness then which is of the law, speaketh on this


wise. “Thou, O man of God, stand fast in love, in the image of God
wherein thou art made. If thou wilt remain in life, keep the
commandments, which are now written in thy heart. Love the Lord
thy God with all thy heart. Love as thyself every soul that he hath
made. Desire nothing but God. Aim at God in every thought, in every
word and work. Swerve not in one motion of body or soul, from him
thy mark and the prize of thy high calling. And let all that is in thee
praise his holy name, every power and faculty of thy soul, in every
kind, in every degree, and at every moment of thine existence. This
do, and thou shalt live: thy light shall shine, thy love shall flame
more and more, till thou art received up into the house of God in the
heavens, to reign with him for ever and ever.”

6. But the righteousness which is of faith speaketh on this wise:


say not in thine heart, who shall ascend into heaven, that is, to bring
down Christ from above (as tho’ it were some impossible task, which
God required thee previously to perform, in order to thine
acceptance:) or, who shall descend into the deep, that is, to bring up
Christ from the dead; (as tho’ that were still remaining to be done,
for the sake of which thou wert to be accepted.) But what saith it?
The word (according to the tenor of which, thou mayst now be
accepted as an heir of life eternal) is nigh thee, even in thy mouth
and in thy heart, that is, the word of faith, which we preach: the
new covenant which God hath now established with sinful man,
through Christ Jesus.

7. By the righteousness which is of faith, is meant, that condition


of justification (and in consequence of present and final salvation, if
we endure therein unto the end) which was given by God to fallen
man, through the merits and mediation of his only begotten Son.
This was in part revealed to Adam soon after his fall, being
contained in the original promise, made to him and his seed,
concerning the seed of the woman, who should bruise the serpent’s
head. 17 It was a little more clearly revealed to Abraham, by the
angel of God from heaven, saying, By myself have I sworn, saith the
Lord, that in thy seed shall all the nations of the earth be blessed. 18
It was yet more fully made known to Moses, to David, and to the
prophets that followed: and through them, to many of the people of
God, in their respective generations. But still the bulk even of these
were ignorant of it; and very few understood it clearly. Still life and
immortality were not so brought to light to the Jews of old, as they
are now unto us by the gospel.

8. Now this covenant saith not to sinful man “Perform unsinning


obedience and live.” If this were the term, he would have no more
benefit by all which Christ hath done and suffered for him, than if he
was required, in order to life, to ascend into heaven and bring down
Christ from above: or to descend into the deep, into the invisible
world, and bring up Christ from the dead. It doth not require any
impossibility to be done; (altho’ to mere man, what it requires would
be impossible; but not, to man assisted by the Spirit of God:) this
were only, to mock human weakness. Indeed, strictly speaking, the
covenant of grace doth not require us, to do any thing at all, as
absolutely and indispensably necessary in order to our justification:
but only, to believe in him, who, for the sake of his Son, and the
propitiation which he hath made, justifieth the ungodly that worketh
not, and imputes his faith to him for righteousness. Even so
Abraham believed in the Lord, and he counted it to him for
righteousness. 19 And he received the sign of circumcision, a seal of
the righteousness of faith—that he might be the father of all them
that believe—that righteousness might be imputed unto them also. 20
Now it was not written for his sake alone, that it (i. e. faith) was
imputed to him. But for us also, to whom it shall be imputed (to
whom faith shall be imputed for righteousness, shall stand in the
stead of perfect obedience, in order to our acceptance with God) if
we believe on him who raised up Jesus our Lord from the dead: who
was delivered to death for our offences, and was raised again for our
justification: 21 “For the assurance of the remission of our sins, and
of a second life to come to them that believe.”

9. What saith then the covenant of forgiveness, of unmerited


love, of pardoning mercy? Believe in the Lord Jesus Christ, and thou
shalt be saved. In the day thou believest, thou shalt surely live.
Thou shalt be restored to the favour of God; and in his pleasure is
life. Thou shalt be saved from the curse and from the wrath of God.
Thou shalt be quickened from the death of sin, into the life of
righteousness. And if thou endure to the end, believing in Jesus,
thou shalt never taste the second death, but having suffered with
thy Lord, shalt also live and reign with him for ever and ever.
10. Now this word is nigh thee. This condition of life, is plain,
easy, always at hand. It is in thy mouth and in thy heart, through
the operation of the Spirit of God. The moment thou believest in
thine heart in him, whom God hath raised from the dead, and
confesseth with thy mouth the Lord Jesus, as thy Lord and thy God,
thou shalt be saved from condemnation, from the guilt and
punishment of thy former sins, and shalt have power to serve God in
true holiness, all the remaining days of thy life.

11. * What is the difference then between the righteousness


which is of the law, and the righteousness which is of faith? Between
the first covenant, or the covenant of works, and the second, the
covenant of grace? The essential, unchangeable difference is this:
the one supposes him to whom it is given, to be already holy and
happy, created in the image and enjoying the favour of God; and
prescribes the condition whereon he may continue therein, in love
and joy, life and immortality. The other supposes him to whom it is
given, to be now unholy and unhappy; fallen short of the glorious
image of God, having the wrath of God abiding on him, and
hastening through sin, whereby his soul is dead, to bodily death, and
death everlasting. And to man in this state, it prescribes the
condition, whereon he may regain the pearl he has lost: may recover
the favour, and the image of God, may retrieve the life of God in his
soul, and be restored to the knowledge and the love of God, which is
the beginning of life eternal.

12. Again, the covenant of works, in order to man’s continuance


in the favour of God, in his knowledge and love, in holiness and
happiness, required of perfect man, a perfect and uninterrupted
obedience, to every point of the law of God. Whereas the covenant
of grace, in order to man’s recovery, of the favour and life of God,
requires only faith; living faith in him, who through God justifies him
that obeyed not.

13. * Yet again: the covenant of works required of Adam and all
his children, to pay the price themselves, in consideration of which,
they were to receive all the future blessings of God. But in the
covenant of grace, seeing we have nothing to pay, God frankly
forgives us all: provided only, that we believe in him, who hath paid
the price for us; who hath given himself a propitiation for our sins,
for the sins of the whole world.

14. Thus the first covenant required what is now afar off from all
the children of men; namely, unsinning obedience, which is far from
those who are conceived and born in sin. Whereas the second
requires what is nigh at hand; as tho’ it should say, Thou art sin:
God is love. Thou by sin art fallen short of the glory of God; yet
there is mercy with him. Bring then all thy sins to the pardoning
God, and they shall vanish away as a cloud. If thou wert not
ungodly, there would be no room for him to justify thee as ungodly.
But now draw near, in full assurance of faith. He speaketh, and it is
done. Fear not, only believe; for even the just God justifieth all that
believe in Jesus.

II. 1. These things considered, it will be easy to shew, as


I proposed to do in the second place, the folly of trusting in the
righteousness which is of the law, and the wisdom of submitting to
the righteousness which is of faith.

The folly of those who still trust, in the righteousness which is of


the law, the terms of which are, Do this and live, may abundantly
appear from thence. They set out wrong. Their very first step is a
fundamental mistake. For before they can ever think of claiming any
blessing on the terms of this covenant, they must suppose
themselves to be in his state, with whom this covenant was made.
But how vain a supposition is this? Since it was made with Adam in a
state of innocence. How weak therefore must that whole building be,
which stands on such a foundation? And how foolish are they who
thus build on the sand? Who seem never to have considered, that
the covenant of works was not given to man, when he was dead in
trespasses and sins, but when he was alive to God, when he knew
no sin, but was holy as God is holy: who forget, that it was never
design’d for the recovery of the favour and life of God once lost, but
only for the continuance and increase thereof, till it should be
compleat in life everlasting.

2. Neither do they consider, who are thus seeking to establish


their own righteousness which is of the law, what manner of
obedience or righteousness that is, which the law indispensably
requires. It must be perfect and entire, in every point, or it answers
not the demand of the law. But which of you is able to perform such
obedience? Or, consequently, to live thereby? Who among you fulfils
every jot and tittle even of the outward commandments of God?
Doing nothing, great or small, which God forbids? Leaving nothing
undone which he enjoins? Speaking no idle word? Having your
conversation always meet to minster grace to the hearers? And
whether you eat or drink, or whatever you do, doing all to the glory
of God? And how much less are you able to fulfil all the inward
commandments of God? Those which require, that every temper and
motion of your soul should be holiness unto the Lord? Are you able,
To love God with all your heart? To love all mankind as your own
soul? To pray without ceasing? In every thing to give thanks? To
have God always before you? And to keep every affection, desire
and thought, in obedience to his law?

3. You should farther consider, that the righteousness of the law


requires, not only the obeying every command of God, negative and
positive, internal and external, but likewise in the perfect degree. In
every instance whatever, the voice of the law is, Thou shalt serve
the Lord thy God with all thy strength. It allows no abatement of any
kind. It excuses no defect. It condemns every coming short of the
full measure of obedience, and immediately pronounces a curse on
the offender. It regards only the invariable rules of justice, and faith,
“I know not to shew mercy.”

4. Who then can appear before such a judge, who is extreme to


mark what is done amiss? How weak are they who desire to be tried
at the bar, where no flesh living can be justified? None of the
offspring of Adam. For suppose we did now keep every
commandment with all our strength: yet one single breach which
ever was, utterly destroys our whole claim to life. If we have ever
offended, in any one point, this righteousness is at an end. For the
law condemns all who do not perform uninterrupted as well as
perfect obedience. So that according to the sentence of this, for him
who hath once sinned, in any degree, there remaineth only a fearful
looking for of fiery indignation, which shall devour the adversaries of
God.

5. Is it not then the very foolishness of folly, for fallen man to


seek life by this righteousness? For man, who was shapen in
wickedness, and in sin did his mother conceive him: man, who is by
nature all earthly, sensual, devilish, altogether corrupt and
abominable: in whom till he find grace, dwelleth no good thing; nay,
who cannot of himself think one good thought? Who is indeed all
sin, a mere lump of ungodliness, and who commits sin in every
breath he draws; whose actual transgressions, in word and deed,
are more in number than the hairs of his head! What stupidity, what
senselesness must it be for such an unclean, guilty, helpless worm
as this, to dream of seeking acceptance by his own righteousness, of
living by the righteousness which is of the law?

6. Now whatsoever considerations prove the folly of trusting in


the righteousness which is of the law, prove equally the wisdom of
submitting to the righteousness which is of God by faith. This were
easy to be shewn with regard to each of the preceding
considerations. But to wave this, the wisdom of the first step hereto,
the disclaiming our own righteousness, plainly appears from hence,
that it is acting according to truth, to the real nature of things. For
what is it more, than to acknowledge with our heart as well as lips,
the true state wherein we are? To acknowledge, that we bring with
us into the world, a corrupt, sinful nature; more corrupt indeed than
we can easily conceive, or find words to express? That hereby we
are prone to all that is evil, and averse from all that is good; that we
are full of pride, self-will, unruly passions, foolish desires; vile and
inordinate affections; lovers of the world, lovers of pleasure more
than lovers of God? That our lives have been no better than our
hearts, but many ways ungodly and unholy; insomuch that our
actual sins, both in word and deed, have been as the stars of heaven
for multitude: that on all these accounts, we are displeasing to him,
who is of purer eyes than to behold iniquity; and deserve nothing
from him, but indignation and wrath and death, the due wages of
sin? That we cannot by any of our righteousness, (for indeed, we
have none at all) nor by any of our works (for they are as the tree
from which they grow) appease the wrath of God, or avert the
punishment we have justly deserved? Yea, that, if left to ourselves,
we shall only wax worse and worse, sink deeper and deeper into sin,
offend God more and more, both with our evil works and with the
evil tempers of our carnal mind, till we fill up the measure of our
iniquities, and bring upon ourselves swift destruction? And is not this
the very state wherein by nature we are? To acknowledge this then,
both with our heart and lips, that is, to disclaim our own
righteousness, the righteousness which is of the law, is to act
according to the real nature of things, and consequently is an
instance of true wisdom.

7. The wisdom of submitting to the righteousness of faith,


appears farther from this consideration, that it is the righteousness
of God: I mean here, it is that method of reconciliation with God,
which hath been chose and established by God himself, not only as
he is the God of wisdom, but as he is the sovereign Lord of heaven
and earth, and of every creature which he hath made. Now, as it is
not meet for man to say unto God, What dost thou? As none who is
not utterly void of understanding, will contend with one that is
mightier than he, with him whose kingdom ruleth over all; so it is
true wisdom, it is a mark of sound understanding, to acquiesce in
whatever he hath chosen, to say in this, as in all things, “It is the
Lord; let him do what seemeth him good.”

8. It may be farther considered, that it was of mere grace, of free


love, of undeserved mercy, that God hath vouchsafed to sinful man,
any way of reconciliation with himself, that we were not cut away
from his hand, and utterly blotted out of his remembrance.
Therefore whatever method he is pleased to appoint, of his tender
mercy, of his unmerited goodness, whereby his enemies, who have
so deeply revolted from him, so long and obstinately rebelled against
him, may still find favour in his sight, it is doubtless our wisdom to
accept with all thankfulness.

9. To mention but one consideration more. It is wisdom to aim at


the best end by the best means. Now the best end which any
creature can pursue, is happiness in God. And the best end a fallen
creature can pursue is, the recovery of the favour and image of God.
But the best, indeed the only means under heaven given to man,
whereby he may regain the favour of God, which is better than life
itself, or the image of God, which is the true life of the soul, is the
submitting to the righteousness which is of faith, the believing in the
only-begotten Son of God.

III. 1. Whosoever therefore thou art who desirest to be forgiven


and reconciled to the favour of God; do not say in thy heart, “I must
first do this; I must first conquer every sin; break off every evil word
and work, and do all good to all men: or, I must first go to church,
receive the Lord’s supper, hear more sermons, and say more
prayers.” Alas, my brother, thou art clean gone out of the way, thou
art still ignorant of the righteousness of God, and art seeking to
establish thy own righteousness, as the ground of thy reconciliation.
Knowest thou not, that thou canst do nothing but sin, ’till thou art
reconciled to God? Wherefore then dost thou say, I must do this and
this first, and then I shall believe. Nay, but first believe. Believe in
the Lord Jesus Christ, the propitiation for thy sins. Let this good
foundation first be laid, and then thou shall do all things well.

Neither say in thy heart, “I can’t be accepted yet, because I am


not good enough.” Who is good enough? Who ever was? To merit
acceptance at God’s hand’s? Was ever any child of Adam good
enough for this? Or will any, till the consummation of all things? And
as for thee, thou art not good at all: there dwelleth in thee no good
thing. And thou never wilt be, till thou believe in Jesus. Rather thou
wilt find thyself worse and worse. But is there any need of being
worse, in order to be accepted? Art thou not bad enough already?
Indeed thou art, and that God knoweth. And thou thyself canst not
deny it. Then delay not. All things are now ready. Arise and wash
away thy sins. The fountain is open. Now is the time, to wash thee
white in the blood of the Lamb. Now he shall purge thee as with
hyssop, and thou shalt be clean; he shall wash thee, and thou shalt
be whiter than snow.

3. Do not say, “But I am not contrite enough: I am not sensible


enough of my sins.” I know it. I would to God, thou wert more
sensible of them, more contrite a thousand fold than thou art. But
do not stay for this. It may be God will make thee so, not before
thou believest, but by believing. It may be, thou wilt not weep
much, till thou lovest much, because thou hast had much forgiven.
In the mean time, look unto Jesus. Behold how he loveth thee! What
could he have done more for thee which he hath not done?

“O Lamb of God, was ever pain,

Was ever love like thine!”

Look steddily upon him, till he looks on thee, and breaks thy hard
heart. Then shall thy head be waters, and thy eyes fountains of
tears.

4. Nor yet do thou say, “I must do something more, before


I come to Christ.” I grant, supposing thy Lord should delay his
coming, it were meet and right to wait for his appearing, in doing, so
far as thou hast power, whatsoever he hath commanded thee. But
there is no necessity for making such a supposition. How knowest
thou that he will delay? Perhaps he will appear, as the day-spring
from on high, before the morning-light. O do not set him a time.
Expect him every hour. Now, he is nigh! Even at the door!

5. And to what end wouldst thou wait for more sincerity, before
thy sins are blotted out? To make thee more worthy of the grace of
God? Alas, thou art still establishing thy own righteousness. He will
have mercy, not because thou art worthy of it, but because his
compassions fail not: not because thou art righteous; but because
Jesus Christ hath atoned for thy sins.

Again, if there be any thing good in sincerity, why dost thou


expect it, before thou hast faith? Seeing faith itself is the only root of
whatever is really good and holy.

Above all, how long wilt thou forget, that whatsoever thou dost,
or whatsoever thou hast, before thy sins are forgiven thee, it avails
nothing with God, toward the procuring of thy forgiveness? Yea, and
that it must all be cast behind thy back, trampled under foot, made
no account of, or thou wilt never find favour in God’s sight: because
until then thou canst not ask it, as a mere sinner, guilty, lost,
undone, having nothing to plead, nothing to offer to God, but only
the merits of his well-beloved Son, who loved thee, and gave himself
for thee.

6. * To conclude. Whosoever thou art, O man, who hast the


sentence of death in thyself, who feelest thyself a condemned sinner,
and hast the wrath of God abiding on thee: unto thee saith the Lord,
Not, do this; perfectly obey all my commands and live: but, Believe
in the Lord Jesus Christ, and thou shalt be saved. The word of faith
is nigh unto thee; now, at this instant, in the present moment, and
in thy present state, sinner as thou art, just as thou art, believe the
gospel: and I will be merciful unto thy unrighteousness and thy
iniquities will I remember no more.
SERMON VII.
MARK i. 15.

The Kingdom of God is at hand: repent ye, and


believe the gospel.

T
HESE words naturally lead us to consider, first, The nature of
true religion, here termed by our Lord, The kingdom of God,
which, saith he, is at hand: and secondly, The way thereto,
which he points out in those words, Repent ye, and believe the
gospel.

I. 1. We are, first, to consider, The nature of true religion, here


term’d by our Lord, The kingdom of God. The same expression the
great apostle uses in his epistle to the Romans, where he likewise
explains his Lord’s words, saying, The kingdom of God is not meat
and drink; but righteousness, and peace, and joy in the Holy Ghost.
Chap. xiv. 17.

2. The kingdom of God, or true religion, is not meat and drink. It


is well known, that not only the unconverted Jews, but great
numbers of those who had received the faith of Christ, were
notwithstanding zealous of the law, (Acts xxi. 20.) even the
ceremonial law of Moses. Whatsoever therefore they found written
therein, either concerning meat and drink-offerings, or the
distinction between clean and unclean meats, they not only
observed themselves, but vehemently pressed the same, even on
those among the Gentiles (or Heathens) who were turned to God.
Yea, to such a degree, that some of them taught, wheresoever they
came among them, Except ye be circumcised, and keep the law,
(the whole ritual law) ye cannot be saved, Acts xv. 1, 24.

3. In opposition to these, the apostle declares, both here and in


many other places, that true religion does not consist in meat and
drink, or in any ritual observances: nor indeed in any outward thing
whatever, in any thing exterior to the heart; the whole substance
thereof lying in righteousness, peace, and joy in the Holy Ghost.

4. Not in any outward thing; such as forms or ceremonies, even


of the most excellent kind. Supposing these to be ever so decent
and significant, ever so expressive of inward things: supposing them
ever so helpful, not only to the vulgar, whose thought reaches little
farther than their sight; but even to men of understanding, men of
stronger capacities, as doubtless they may sometimes be: yea,
supposing them, as in the case of the Jews, to be appointed by God
himself; yet even during the period of time wherein that
appointment remains in force, true religion does not principally
consist therein; nay, strictly speaking, not at all. How much more
must this hold concerning such rites and forms, as are only of
human appointment? The religion of Christ rises infinitely higher, and
lies immensely deeper than all these. These are good in their place;
just so far as they are in fact subservient to true religion. And it were
superstition to object against them, while they are applied only as
occasional helps to human weakness. But let no man carry them
farther. Let no man dream, that they have any intrinsick worth: or
that religion cannot subsist without them. This were to make them
an abomination to the Lord.
5. The nature of religion is so far from consisting in these, in
forms of worship, or rites and ceremonies, that it does not properly
consist in any outward actions, of what kind soever. It is true, a man
cannot have any religion, who is guilty of vicious, immoral actions;
or who does to others, what he would not they should do to him, if
he were in the same circumstance. And it is also true, that he can
have no real religion, who knows to do good, and doth it not. Yet
may a man both abstain from outward evil, and do good, and still
have no religion. Yea, two persons may do the same outward work,
suppose, feeding the hungry, or cloathing the naked: and, mean
time, one of these may be truly religious, and the other have no
religion at all: for the one may act from the love of God, and the
other from the love of praise. So manifest it is; that altho’ true
religion naturally leads to every good word and work, yet the real
nature thereof lies deeper still, even in the hidden man of the heart.

6. I say, of the heart. For neither does religion consist in


orthodoxy or right opinions; which altho’ they are not properly
outward things, are not in the heart, but the understanding. A man
may be orthodox in every point; he may not only espouse right
opinions, but zealously defend them against all opposers: he may
think justly concerning the incarnation of our Lord, concerning the
ever blessed Trinity, and every other doctrine, contained in the
oracles of God: He may assent to all the three creeds: that called the
apostles’, the Nicene, and the Athanasian: and yet ’tis possible, he
may have no religion at all, no more than a Jew, Turk, or Pagan. He
may be almost as orthodox as――the devil; (tho’ indeed, not
altogether. For every man errs in something; whereas we can’t well
conceive him to hold any erroneous opinion) and may all the while
be as great a stranger as he, to the religion of the heart.

7. This alone is religion, truly so call’d: this alone is in the sight of


God of great price. The apostle sums it all up in three particulars,
righteousness, and peace, and joy in the Holy Ghost. And first,
righteousness. We cannot be at a loss concerning this, if we
remember the words of our Lord describing the two grand branches
thereof, on which hang all the law and the prophets. Thou shalt love
the Lord thy God with all thy heart, and with all thy mind, and with
all thy soul, and with all thy strength. 22 This is the first and great
commandment, the first and great branch of Christian righteousness.
Thou shalt delight thyself in the Lord thy God; thou shalt seek and
find all happiness in him. He shall be thy shield, and thy exceeding
great reward, in time and in eternity. All thy bones shall say, Whom
have I in heaven but thee? And there is none upon earth that
I desire beside thee! Thou shalt hear, and fulfil his word who saith,
My son, give me thy heart. And having given him thy heart, thy
inmost soul, to reign there without a rival, thou mayest well cry out,
in the fulness of thy heart, I will love thee, O Lord, my strength. The
Lord is my strong rock and my defence: my Saviour, my God, and
my might, in whom I will trust; my buckler, the horn also of my
salvation, and my refuge.

8. And the second commandment is like unto this; the second


great branch of Christian righteousness is closely and inseparably
connected therewith, even Thou shalt love thy neighbour as thyself.
Thou shalt love—Thou shalt embrace with the most tender good-will,
the most earnest and cordial affection, the most inflamed desires of
preventing or removing all evil, and of procuring for him every
possible good. Thy neighbour—that is, not only thy friend, thy
kinsman, or thy acquaintance; not only the virtuous, the friendly,
him that loves thee, that prevents or returns thy kindness; but every
child of man, every human creature, every soul which God hath
made: not excepting him whom thou never hast seen in the flesh,
whom thou knowest not either by face or name: not excepting him
whom thou knowest to be evil and unthankful, him that still
despightfully uses and persecutes thee. Him thou shalt love as
thyself; with the same invariable thirst after his happiness in every
kind: the same unwearied care to skreen him from whatever might
grieve or hurt either his soul or body.

9. Now is not this love the fulfilling of the law? The sum of all
Christian righteousness? Of all inward righteousness; for it
necessarily implies bowels of mercies, humbleness of mind (seeing
love is not puffed up) gentleness, meekness, long-suffering, (for love
is not provoked but believeth, hopeth, endureth all things) and of all
outward righteousness; for love worketh no evil to his neighbour,
either by word or deed. It cannot willingly either hurt or grieve any
one. And it is zealous of good works. Every lover of mankind, as he
hath opportunity, doth good unto all men; being (without partiality
and without hypocrisy) full of mercy and good fruits.

10. But true religion, or a heart right toward God and man,
implies happiness as well as holiness. For it is not only
righteousness, but also peace and joy in the Holy Ghost. What
peace? The peace of God, which God only can give and the world
cannot take away: the peace which passeth all understanding, all
(barely) rational conception; being a supernatural sensation, a divine
taste of the powers of the world to come: such as the natural man
knoweth not, how wise soever in the things of this world: nor indeed
can he know it, in his present state, because it is spiritually
discerned. It is a peace that banishes all doubt, all painful
uncertainty; the Spirit of God bearing witness with the spirit of a
Christian, that he is a child of God. And it banishes fear, all such fear
as hath torment; the fear of the wrath of God, the fear of hell, the
fear of the devil, and in particular, the fear of death: he that hath the
peace of God, desiring (if it were the will of God) to depart and to be
with Christ.

11. With this peace of God, wherever it is fix’d in the soul, there
is also joy in the Holy Ghost: joy wrought in the heart by the Holy
Ghost, by the ever blessed Spirit of God. He it is that worketh in us
that calm, humble rejoicing in God, through Christ Jesus, by whom
we have now received the atonement, καταλλαγὴν, the reconciliation
with God; and that enables us boldly to confirm the truth of the
royal Psalmist’s declaration, Blessed is the man (or rather happy)
whose unrighteousness is forgiven, and whose sin is covered. He it
is that inspires the Christian soul, with that even, solid joy, which
arises from the testimony of the Spirit, that he is a child of God; and
that gives him to rejoice with joy unspeakable, in hope of the glory
of God: Hope, both of the glorious image of God, which is in part
and shall be fully revealed in him; and of that crown of glory, which
fadeth not away, reserved in heaven for him.

12. This holiness and happiness joined in one, are sometimes


stiled in the inspired writings, the kingdom of God, (as by our Lord in
the text) and sometimes, the kingdom of heaven. It is termed the
kingdom of God, because it is the immediate fruit of God’s reigning
in the soul. So soon as ever he takes unto himself his mighty power,
and sets up his throne in our hearts, they are instantly filled with this
righteousness and peace and joy in the Holy Ghost. It is called the
kingdom of heaven, because it is (in a degree) heaven opened in the
soul. For whosoever they are that experience this, they can aver,
before angels and men,

“Everlasting life is won:

Glory is on earth begun:”

According to the constant tenor of scripture, which every where


bears record, God hath given unto us eternal life, and this life is in
his Son. He that hath the Son (reigning in his heart) hath life, (even
life everlasting) 1 John v. 11, 12. For this is life eternal, to know
thee, the only true God, and Jesus Christ whom thou has sent, John
xvii. 3. And they to whom this is given, may confidently address
God, tho’ they were in the midst of a fiery furnace,
“Thee—Lord, safe shielded by thy pow’r,

Thee, Son of God, Jehovah, we adore;

In form of man descending to appear:

To thee be ceaseless hallelujah’s given.

Praise, as in heaven thy throne, we offer here;

For where thy presence is display’d, is heaven.”

13. And this kingdom of God or of heaven is at hand. As these


words were originally spoken, they implied, that the time was then
fulfilled, God being made manifest in the flesh, when he would set-
up his kingdom among men, and reign in the hearts of his people.
And is not the time now fulfilled? For lo! saith he, I am with you
always, you who preach remission of sins in my name, even unto the
end of the world. (Matt. xxviii. 20.) Wheresoever therefore the
gospel of Christ is preached, this his kingdom is nigh at hand. It is
not far from every one of you. Ye may this hour enter thereinto, if so
be ye hearken to his voice, repent ye, and believe the gospel.

II. 1. This is the way. Walk ye in it. And first, repent, that is,
know yourselves. This is the first repentance, previous to faith; even
conviction, or self-knowledge. Awake then thou that sleepest. Know
thyself to be a sinner, and what manner of sinner thou art. Know
that corruption of thy inmost nature, whereby thou art very far gone
from original righteousness, whereby the flesh lusteth always
contrary to the spirit, through that carnal mind which is enmity
against God, which is not subject to the law of God, neither indeed
can be. Know that thou art corrupted in every power, in every faculty
of thy soul; that thou art totally corrupted in every one of these, all
the foundations being out of course. The eyes of thine
understanding are darkned, so that they cannot discern God or the
things of God. The clouds of ignorance and error rest upon thee, and
cover thee with the shadow of death. Thou knowest nothing yet, as
thou oughtest to know, neither God, nor the world, nor thyself. Thy
will is no longer the will of God, but is utterly perverse and distorted,
averse from all good, from all which God loves, and prone to all evil,
to every abomination which God hateth. Thy affections are alienated
from God, and scattered abroad over all the earth. All thy passions,
both thy desires and aversions, thy joys and sorrows, thy hopes and
fears, are out of frame, are either undue in their degree, or placed
on undue objects. So that there is no soundness in thy soul; but
from the crown of the head to the sole of the foot (to use the strong
expression of the prophet) there are only wounds and bruises and
putrifying sores.

2. Such is the inbred corruption of thy heart, of thy very inmost


nature. And what manner of branches canst thou expect to grow,
from such an evil root? Hence springs unbelief, ever departing from
the living God: Saying, “Who is the Lord that I should serve him?
Tush! Thou, God, carest not for it.” Hence independence, affecting to
be like the Most High; hence pride in all its forms, teaching thee to
say, “I am rich, and increased in goods, and have need of nothing.”
From this evil fountain flow forth the bitter streams of vanity, thirst
of praise; ambition, covetousness; the lust of the flesh, the lust of
the eye, and the pride of life. From this arise anger, hatred, malice,
revenge, envy, jealousy, evil-surmisings: from this all the foolish and
hurtful lusts, that now pierce thee through with many sorrows, and if
not timely prevented, will at length drown thy soul in everlasting
perdition.

3. And what fruits can grow on such branches as these? Only


such as are bitter and evil continually. Of pride cometh contention,
vain boasting, seeking and receiving praise of men, and so robbing
God of that glory which he cannot give unto another. Of the lust of
the flesh come gluttony or drunkenness, luxury or sensuality:
fornication, uncleanness, variously defiling that body, which was
designed for a temple of the Holy Ghost: of unbelief, every evil word
and work. But the time would fail, shouldst thou reckon up all; all
the idle words thou hast spoken, provoking the Most High, grieving
the Holy One of Israel: all the evil works thou hast done, either
wholly evil in themselves, or at least, not done to the glory of God.
For thy actual sins are more than thou art able to express, more
than the hairs of thy head. Who can number the sands of the sea, or
the drops of rain, or thy iniquities?

4. And knowest thou not, that the wages of sin is death? Death
not only temporal, but eternal. The soul that sinneth it shall die: for
the mouth of the Lord hath spoken it. It shall die the second death.
This is the sentence, to be punished with never-ending death, with
everlasting destruction from the presence of the Lord, and from the
glory of his power. Knowest thou not that every sinner, ἔνοχος ἐστι
τῆ γεέννῃ τοῦ πυρός; not properly is in danger of hell-fire, that
expression is far too weak: but rather, is under the sentence of hell-
fire, doom’d already, just dragging to execution. Thou art guilty of
everlasting death. It is the just reward of thy inward and outward
wickedness. It is just, that the sentence should now take place. Dost
thou see, dost thou feel this? Art thou throughly convinced, that
thou deservest God’s wrath and everlasting damnation? Would God
do thee no wrong, if he now commanded the earth to open and
swallow thee up? If thou wert now to go down quick into the pit,
into the fire that never shall be quenched? If God hath given thee
truly to repent, thou hast a deep sense that these things are so; and
that it is of his mere mercy thou art not consumed, swept away from
the face of the earth.

5. And what wilt thou do to appease the wrath of God, to atone


for all thy sins, and to escape the punishment thou hast so justly
deserved? Alas, thou canst do nothing: nothing that will in any wise
make amends to God, for one evil work, or word, or thought. If thou
couldst now do all things well, if from this very hour, till thy soul
should return to God, thou couldst perform perfect uninterrupted
obedience, even this would not atone for what is past. The not
increasing thy debt would not discharge it. It would still remain as
great as ever. Yea, the present and future obedience of all the men
upon earth, and all the angels in heaven, would never make
satisfaction to the justice of God for one single sin. How vain then
was the thought, of atoning for thy own sins by any thing thou
couldst do? It costeth far more to redeem one soul, than all mankind
is able to pay. So that were there no other help for a guilty sinner,
without doubt he must have perished everlastingly.

6. But suppose perfect obedience for the time to come, could


atone for the sins that are past, this would profit thee nothing; for
thou art not able to perform it; no, not in any one point. Begin now.
Make the trial. Shake off that outward sin that so easily besetteth
thee. Thou canst not. How then wilt thou change thy life from all evil
to all good? Indeed, it is impossible to be done, unless first thy heart
be changed. For so long as the tree remains evil, it cannot bring
forth good fruit. But art thou able to change thy own heart, from all
sin to all holiness? To quicken a soul that is dead in sin? Dead to God
and alive only to the world? No more than thou art able to quicken a
dead body, to raise to life him that lieth in the grave. Yea, thou art
not able to quicken thy soul in any degree, no more than to give any
degree of life to the dead body. Thou canst do nothing more or less,
in this matter; thou art utterly without strength. To be deeply
sensible of this, how helpless thou art, as well as how guilty and
how sinful, this is that repentance not to be repented of, which is
the fore-runner of the kingdom of God.

7. If to this lively conviction of thy inward and outward sins, of


thy utter guiltiness and helplessness, there be added suitable
affections sorrow of heart, for having despised thy own mercies,
remorse and self-condemnation, having the mouth stop’d, shame to
lift up thine eyes to heaven; fear of the wrath of God abiding on
thee, of his curse hanging over thy head, and of the fiery indignation
ready to devour those who forget God, and obey not our Lord Jesus
Christ: earnest desire to escape from that indignation, to cease from
evil and learn to do well: then I say unto thee, in the name of the
Lord, thou art not far from the kingdom of God. One step more and
thou shalt enter in. Thou dost repent. Now, believe the gospel.
8. The gospel (that is, good tidings, good news for guilty,
helpless sinners) in the largest sense of the word, means, the whole
revelation made to men by Jesus Christ: and sometimes the whole
account of what our Lord did and suffered, while he tabernacled
among men. The substance of all is, Jesus Christ came into the
world to save sinners. Or, God so loved the world, that, he gave his
only begotten Son, to the end we might not perish, but have
everlasting life. Or, he was bruised for our transgressions, he was
wounded for our iniquities: the chastisement of our peace was upon
him, and with his stripes we are healed.

9. Believe this and the kingdom of God is thine. By faith thou


attainest the promise. “He pardoneth and absolveth all that truly
repent and unfeignedly believe his holy gospel.” As soon as ever God
hath spoken to thy heart “Be of good chear, thy sins are forgiven
thee,” his kingdom comes; thou hast righteousness and peace, and
joy in the Holy Ghost.

10. Only beware thou do not deceive thy own soul, with regard
to the nature of this faith. It is not (as some have fondly conceived)
a bare assent to the truth of the bible, of the articles of our creed, or
of all that is contained in the old and new testament. The devils
believe this, as well as I or thou, and yet they are devils still. But it
is, over and above this, a sure trust in the mercy of God through
Christ Jesus. It is a confidence in a pardoning God. It is a divine
evidence or conviction, that God was in Christ reconciling the world
to himself, not imputing to them their former trespasses: and in
particular, that the Son of God hath loved me and given himself for
me: and that I, even I, am now reconciled to God by the blood of
the cross.

11. Dost thou thus believe? Then the peace of God is in thy
heart, and sorrow and sighing flee away. Thou art no longer in doubt
of the love of God: it is clear as the noon-day sun. Thou cryest out,
My song shall be always of the loving kindness of the Lord: with my
mouth will I ever be telling of thy truth, from one generation to
another. Thou art no longer afraid of hell, or death, or him that had
once the power of death, the devil: no, nor painfully afraid of God
himself; only thou hast a tender, filial fear of offending him. Dost
thou believe? Then thy soul doth magnify the Lord, and thy spirit
rejoiceth in God thy Saviour. Thou rejoicest in that thou hast
redemption thro’ his blood, even the forgiveness of sins. Thou
rejoicest in that Spirit of adoption, which crieth in thy heart, Abba,
Father! Thou rejoicest in a hope full of immortality, in reaching forth
unto the mark of the prize of thy high calling; in an earnest
expectation of all the good things which God hath prepared for them
that love him.

12. Dost thou now believe? Then the love of God is now shed
abroad in thy heart. Thou lovest him, because he first loved us. And
because thou lovest God, thou lovest thy brother also. And being
filled with love, peace, joy, thou art also filled with long-suffering,
gentleness, fidelity, goodness, meekness, temperance, and all the
other fruits of the same Spirit: in a word, with whatever dispositions
are holy, are heavenly or divine. For while thou beholdest with open,
uncovered face, (the veil now being taken away) the glory of the
Lord, his glorious love, and the glorious image wherein thou wast
created, thou art changed into the same image, from glory to glory,
by the Spirit of the Lord.

13. This repentance, this faith, this peace, joy, love; this change
from glory to glory, is what the wisdom of the world has voted to be
madness, mere enthusiasm, utter distraction. But thou, O man of
God, regard them not: be thou moved by none of these things. Thou
knowest in whom thou hast believed. See that no man take thy
crown. Whereunto thou hast already attained hold fast; and follow,
till thou attain all the great and precious promises. And thou who
hast not yet known him, let not vain men make thee ashamed of the
gospel of Christ. Be thou in nothing terrified by those who speak evil
of the things which they know not. God will soon turn thy heaviness
into joy. O let not thy hands hang down. Yet a little longer, and he
will take away thy fears, and give thee the spirit of a sound mind. He
is nigh that justifieth: who is he that condemneth? It is Christ that
died; yea rather that rose again; who is even now at the right-hand
of God, making intercession for thee. Now cast thyself on the Lamb
of God, with all thy sins, how many soever they be; and an entrance
shall now be ministred unto thee, into the kingdom of our Lord and
Saviour Jesus Christ!
SERMON VIII.
THE FIRST-FRUITS OF THE
SPIRIT.
ROM. viii. 1.

There is therefore now no condemnation to them


which are in Christ Jesus, who walk not after the
flesh, but after the Spirit.

B
1. Y them which are in Christ Jesus, St. Paul evidently means,
those who truly believe in him: those who being justified by
faith, have peace with God, through our Lord Jesus Christ.
They who thus believe do no longer walk after the flesh, no longer
follow the motions of corrupt nature: but after the Spirit: both their
thoughts, words and works, are under the direction of the blessed
Spirit of God.

2. There is therefore now no condemnation to these. There is no


condemnation to them from God: for he hath justified them freely by
his grace, thro’ the redemption that is in Jesus. He hath forgiven all

You might also like