Java Foundations Introduction to Program Design and Data Structures (5th Edition) John Lewis instant download
Java Foundations Introduction to Program Design and Data Structures (5th Edition) John Lewis instant download
https://ebookmeta.com/product/java-foundations-introduction-to-
program-design-and-data-structures-5th-edition-john-lewis/
https://ebookmeta.com/product/java-foundations-introduction-to-
program-design-and-data-structures-4th-edition-john-lewis/
https://ebookmeta.com/product/data-structures-in-java-1st-
edition-oswald-campesato/
https://ebookmeta.com/product/introduction-to-software-design-
with-java-martin-p-robillard/
https://ebookmeta.com/product/governance-and-performance-
management-in-public-universities-current-research-and-
practice-1st-edition-eugenio-caperchione/
Introduction to Datafication: Implement Datafication
Using AI and ML Algorithms 1st Edition Shivakumar R.
Goniwada
https://ebookmeta.com/product/introduction-to-datafication-
implement-datafication-using-ai-and-ml-algorithms-1st-edition-
shivakumar-r-goniwada/
https://ebookmeta.com/product/sticky-sweet-filthy-dirty-
summer-1st-edition-kat-baxter-2/
https://ebookmeta.com/product/disney-zootopia-hard-day-s-work-
younger-readers-graphic-novel-1st-edition-jimmy-gownley/
https://ebookmeta.com/product/indebted-to-intervene-critical-
lessons-in-debt-communication-art-and-theoretical-practice-1st-
edition-oliver-vodeb-nikola-janovic-kolenc/
https://ebookmeta.com/product/multi-site-network-and-security-
services-with-nsx-t-implement-network-security-stateful-services-
and-operations-1st-edition-iwan-hoogendoorn/
Wicked as Lies Zyron Tessa Part One Shayla Black
https://ebookmeta.com/product/wicked-as-lies-zyron-tessa-part-
one-shayla-black/
To my wife, Sharon, for everything.
– John
To my wonderful wife Susan, and our children, Grace, Anthony, Adam, Lily, EJ, and Peter IV.
Your continued love and support keep me going as always.
– Pete
vii
viii PREFACE
Your feedback has indicated that this approach is working well and we have
continued and reinforced its use. It clarifies the distinction between the way the
Java API supports a particular collection and the way it might be implemented
from scratch. It makes it easier for instructors to point out limitations of the API
implementations in a compare-and-contrast fashion. This approach also allows
an instructor, on a case-by-case basis, to simply introduce a collection without
exploring implementation details if desired.
Chapter Breakdown
Chapter 1 (Introduction) introduces the Java programming language and the
basics of program development. It contains an introduction to object-oriented
development, including an overview of concepts and terminology. This chapter
contains broad introductory material that can be covered while students become
familiar with their development environment.
Chapter 2 (Data and Expressions) explores some of the basic types of data used
in a Java program and the use of expressions to perform calculations. It discusses
the conversion of data from one type to another, and how to read input interac-
tively from the user with the help of the Scanner class.
Chapter 3 (Using Classes and Objects) explores the use of predefined classes
and the objects that can be created from them. Classes and objects are used to
manipulate character strings, produce random numbers, perform complex calcu-
lations, and format output. Packages, enumerated types, and wrapper classes are
also discussed.
Chapter 4 (Conditionals and Loops) covers the use of Boolean expressions to
make decisions. All related statements for conditionals and loops are discussed,
P R E FAC E ix
including the enhanced version of the for loop. The Scanner class is revisited for
iterative input parsing and reading text files.
Chapter 5 (Writing Classes) explores the basic issues related to writing classes
and methods. Topics include instance data, visibility, scope, method parame-
ters, and return types. Constructors, method design, static data, and method
overloading are covered as well. Testing and debugging are now covered in this
chapter as well.
Chapter 6 (Graphical User Interfaces) is an exploration of GUI processing us-
ing the JavaFX platform, focusing on controls, events, and event handlers. Several
types of controls are discussed using numerous GUI examples. Mouse events, key-
board events, and layout panes are also explored.
Chapter 7 (Arrays) contains extensive coverage of arrays and array process-
ing. Topics include bounds checking, initializer lists, command-line arguments,
variable-length parameter lists, and multidimensional arrays.
Chapter 8 (Inheritance) covers class derivations and associated concepts such as
class hierarchies, overriding, and visibility. Strong emphasis is put on the proper
use of inheritance and its role in software design.
Chapter 9 (Polymorphism) explores the concept of binding and how it relates
to polymorphism. Then we examine how polymorphic references can be accom-
plished using either inheritance or interfaces. Design issues related to polymor-
phism are examined as well.
Chapter 10 (Exceptions) covers exception handling and the effects of uncaught
exceptions. The try-catch statement is examined, as well as a discussion of ex-
ception propagation. The chapter also explores the use of exceptions when dealing
with input and output, and examines an example that writes a text file.
Chapter 11 (Analysis of Algorithms) lays the foundation for determining the ef-
ficiency of an algorithm and explains the important criteria that allow a developer
to compare one algorithm to another in proper ways. Our emphasis in this chapter
is understanding the important concepts more than getting mired in heavy math
or formality.
Chapter 12 (Introduction to Collections—Stacks) establishes the concept of a
collection, stressing the need to separate the interface from the implementation. It
also conceptually introduces a stack, then explores an array-based implementation
of a stack.
Chapter 13 (Linked Structures—Stacks) discusses the use of references to create
linked data structures. It explores the basic issues regarding the management of
linked lists, and then defines an alternative implementation of a stack (introduced
in Chapter 12) using an underlying linked data structure.
Chapter 14 (Queues) explores the concept and implementation of a first-in,
first-out queue. The Java API Queue interface is discussed, as are linked and circu-
lar array implementations with Queue in code font.
x PREFACE
Chapter 15 (Lists) covers three types of lists: ordered, unordered, and indexed.
These three types of lists are compared and contrasted, with discussion of the op-
erations that they share and those that are unique to each type. Inheritance is used
appropriately in the design of the various types of lists, which are implemented
using both array-based and linked representations.
Chapter 16 (Iterators) is a new chapter that isolates the concepts and implemen-
tation of iterators, which are so important to collections. The expanded discussion
drives home the need to separate the iterator functionality from the details of any
particular collection.
Chapter 17 (Recursion) is a general introduction to the concept of recursion
and how recursive solutions can be elegant. It explores the implementation details
of recursion and discusses the basic idea of analyzing recursive algorithms.
Chapter 18 (Searching and Sorting) discusses the linear and binary search al-
gorithms, as well as the algorithms for several sorts: selection sort, insertion sort,
bubble sort, quick sort, and merge sort. Programming issues related to searching
and sorting, such as using the Comparable interface as the basis of comparing
objects, are stressed in this chapter. An application uses animation to demonstrate
the efficiency of sorting algorithms. The comparator interface is examined and
demonstrated as well.
Chapter 19 (Trees) provides an overview of trees, establishing key terminology
and concepts. It discusses various implementation approaches and uses a binary
tree to represent and evaluate an arithmetic expression.
Chapter 20 (Binary Search Trees) builds off of the basic concepts established
in Chapter 10 to define a classic binary search tree. A linked implementation of a
binary search tree is examined, followed by a discussion of how the balance in the
tree nodes is key to its performance. That leads to exploring AVL and red/black
implementations of binary search trees.
Chapter 21 (Heaps and Priority Queues) explores the concept, use, and imple-
mentations of heaps and specifically their relationship to priority queues. A heap
sort is used as an example of its usefulness as well. Both linked and array-based
implementations are explored.
Chapter 22 (Sets and Maps) explores these two types of collections and their
importance to the Java Collections API.
Chapter 23 (Multi-way Search Trees) is a natural extension of the discussion of
the previous chapters. The concepts of 2-3 trees, 2-4 trees, and general B-trees are
examined and implementation options are discussed.
Chapter 24 (Graphs) explores the concept of undirected and directed graphs
and establishes important terminology. It examines several common graph algo-
rithms and discusses implementation options, including adjacency matrices.
Chapter 25 (Databases) explores the concept of databases and their manage-
ment, and discusses the basics of SQL queries. It then explores the techniques for
P R E FAC E xi
establishing a connection between a Java program and a database, and the API
used to interact with it.
Supplements
The following student resources are available for this book:
• Source code for all programs presented in the book
• VideoNotes that explore select topics from the book
Resources can be accessed at www.pearson.com/lewis
The following instructor resources can be found at Pearson Education’s Instructor
Resource Center:
• Solutions for select exercises and programming projects in the book
• PowerPoint slides for the presentation of the book content
• Test bank
To obtain access, please visit www.pearsonhighered.com/irc or contact your local
Pearson Education sales representative.
Contents
Prefacevii
Creditsxxix
VideoNotesxxxi
Chapter 1 Introduction 1
1.1 The Java Programming Language 2
A Java Program 3
Comments 5
Identifiers and Reserved Words 7
White Space 9
xiii
xiv CONTENTS
2.4 Expressions 51
Arithmetic Operators 51
Operator Precedence 52
Increment and Decrement Operators 56
Assignment Operators 57
3.3 Packages 83
The import Declaration 84
"Kreikastako?"
Kuka oli tuo ostaja? Oliko hän mies? Vai oliko hän nainen?
Astunnasta ja parrattomista kasvoista päättäen hän oli noin
viidenkymmenen vuotias nainen. Mutta vaatteista, roimahousuista,
puserosta ja hatusta, jommoista omnihussin ohjaajat käyttivät, olisi
luullut häntä mieheksi, etenkin kun hänellä alati oli hampaissa pieni
piipunnysä, joka ei hetkeksikään eksynyt hänen suustansa. Mutta
hänen kasvonsa ne kuitenkin enimmin vetivät Perrinen huomiota
puoleensa, hän kun koetti niistä lukea oliko tuo ostaja häijyn vai
hyvännäköinen ja ne ilmaisivat hyväluontoisuutta eikä kovuutta tahi
pahuutta.
"Saa nähdä onko helpompi saada se nyt sinne kuin ensi kerralla",
arveli
La Rouquerie.
"Potkaiskaa elukkaa!"
Viides luku.
"Tänäänkö?"
"Niin tämä tuoksuu hyvälle", vakuutti Markiisitar, "ja jos mikään voi
pelastaa rouva raukkaa, niin tämä sen tekee; mutta" — tässä hän
hiljensi äänensä kuiskaukseksi — "tiedättehän että hän on kovin
heikko: se ei voi enää kestää kauan."
Kun knppi oli täysi, Markiisitar otti sen ja astui hyvin varovasti,
ettei suinkaan läikyttäisi siitä pisaraakaan.
Mutta sitä kesti päiviä, sillä elämä, joka vanhoissa väleen sammuu,
on voimakkaampi nuorissa: hän ei tullut terveemmäksi eikä
heikontunutkaan, ja vaikka hän ei voinut nauttia ravinnon
rahtustakaan eikä lääkkeitä ja vaikka hän makasi siinä ikäänkuin
nukkuen ihan liikkumatta, välistä melkeinpä hengittämättä, niin hän
eli kuitenkin.
"Äiti, äiti!"
"Näin sinnt… niin, näin sinut ooneliisena… Oi! Jospa saisin kuolla
siinä uskossa ja toivossa että muistoni aina pysyy elävänä
sydämessäsi!"
"Kyllä."
Kuudes luku.
"Lähellä Amiensia."
"Osaatko sinne?"
"Jos tahdot eksyä Parisissa", hän lausui, "niin kuuntele vaan heitä.
Näin sinun pitää tehdä: mene paikallisjunalla Chapelle Nordin
assmalle, siellä on Amiensin tie ihan edessäsi eikä sinun tarvitse
muuta kuin seurata sitä ja silloin kyllä tulet toimeen oppaallasi. Lippn
ei maksa kuin kuusi sousta. Milloin aiot lähteä?"
Oliko se mahdollista?
Hänen tuli vaan pysyä maantiellä ja kun aurinko vielä valaisi pari
kolme tuntia niin hän toivoi ennen pimeän tuloa ehtivänsä siksi
kauas Parisista että voisi nukkua jossakin pensaikossa, joka hänen
mielestänsä oli turvallisin paikka.
Eikö tämä Parisi siis koskaan lopu! Eikö hän milloinkaan pääse siitä
pois! Ei maalaiselämän yksinäisyys, yön hiljaisuus häntä pelottanut,
vaan häntä kammoksutti päinvastoin Parisi, sen talot, sen aaltoillevat
väkijoukot ja sen häikäisevä valo.
"Enhän, rouvaseni!"
"… joka koetat kaupita väärää rahaa. Korjaa luusi, senkin lutus,
maankiertäjä! Odotappas vaan niin haen polisin!"
"Jotta ehkä voisit kaupitella sitä muualla, eikö niin? Eipäs, rahan
minä pidäo. Etsi polisi jos tahdot, niin tutkitaan se yhdessä. Ja mene
matkoihisi nyt, senkin varas ja heittiö, ja sukkelaan!"
"Mitä on tapahtunut?"