Introduction to Programming with Java 3rd Edition John Dean download
Introduction to Programming with Java 3rd Edition John Dean download
https://ebookultra.com/download/introduction-to-programming-with-
java-3rd-edition-john-dean/
https://ebookultra.com/download/introduction-to-java-programming-
brief-8th-edition-edition-y-daniel-liang/
https://ebookultra.com/download/introduction-to-neural-networks-with-
java-2nd-edition-jeff-heaton/
Beginning Programming with Python For Dummies 3rd Edition
John Paul Mueller
https://ebookultra.com/download/beginning-programming-with-python-for-
dummies-3rd-edition-john-paul-mueller/
https://ebookultra.com/download/practical-database-programming-with-
java-1st-edition-ying-bai/
https://ebookultra.com/download/dean-dyer-introduction-to-
intellectual-property-law-1st-edition-owen-dean/
https://ebookultra.com/download/python-programming-an-introduction-to-
computer-science-john-m-zelle/
https://ebookultra.com/download/beginning-programming-with-java-for-
dummies-4th-edition-barry-burd/
Introduction to Programming with Java 3rd Edition John
Dean Digital Instant Download
Author(s): John Dean, Ray Dean
ISBN(s): 9781259875762, 1259875768
Edition: 3
File Details: PDF, 92.85 MB
Year: 2020
Language: english
Page i
John Dean
Park University
Raymond Dean
University of Kansas
Page ii
Published by McGraw Hill LLC, 1325 Avenue of the Americas, New York, NY 10121.
Copyright ©2021 by McGraw Hill LLC. All rights reserved. Printed in the United States of
America. No part of this publication may be reproduced or distributed in any form or by any
means, or stored in a database or retrieval system, without the prior written consent of
McGraw Hill LLC, including, but not limited to, in any network or other electronic storage or
transmission, or broadcast for distance learning.
Some ancillaries, including electronic and print components, may not be available to
customers outside the United States.
1 2 3 4 5 6 7 8 9 LCR 24 23 22 21 20
ISBN 978-1-26057524-8
MHID 1-260-57524-1
All credits appearing on page or at the end of the book are considered to be an extension of
the copyright page.
The Internet addresses listed in the text were accurate at the time of publication. The
inclusion of a website does not indicate an endorsement by the authors or McGraw Hill LLC,
and McGraw Hill LLC does not guarantee the accuracy of the information presented at these
sites.
mheducation.com/highered
Page iii
edication
—To Stan and Kate
Page iv
John Dean is an Associate Professor in the Computer Science and Information Systems
Department at Park University. He earned a Ph.D. degree in computer science from Nova
Southeastern University and an M.S. degree in computer science from the University of
Kansas. He is Java certified and has worked in industry as a software engineer and project
manager, specializing in Java and various web technologies—JavaScript, JavaServer Pages,
and servlets. He has taught a full range of computer science courses, including Java
programming and Java-based web programming. He has authored a web programming
textbook with a focus on client-side technologies HTML5, CSS, and JavaScript.
Contents
Preface x
Project Summary xxiv
CHAPTER 1
CHAPTER 2
Algorithms and Design 32
2.1 Introduction 32
2.2 Output 33
2.3 Variables 34
2.4 Operators and Assignment Statements 35
2.5 Input 36
2.6 Flow of Control and Flowcharts 37
2.7 if Statements 38
2.8 Loops 43
2.9 Loop Termination Techniques 45
2.10 Nested Looping 48
2.11 Tracing 51
2.12 Problem Solving: Other Pseudocode Formats and an Asset Management
Example 55
CHAPTER 3
Java Basics 65
3.1 Introduction 66
3.2 “I Have a Dream” Program 66
3.3 Comments and Readability 67
3.4 The Class Heading 69
3.5 The main Method’s Heading 69
3.6 Braces 70
3.7 System.out.println 71
3.8 Compilation and Execution 73
3.9 Identifiers 73
3.10 Variables 74
3.11 Assignment Statements 75
3.12 Initialization Statements 77
3.13 Numeric Data Types—int, long, float, double 78
3.14 Constants 80
3.15 Arithmetic Operators 83
3.16 Expression Evaluation and Operator Precedence 86
3.17 More Operators: Increment, Decrement, and Compound Assignment 88
3.18 Tracing 90
3.19 Type Casting 90
3.20 char Type and Escape Sequences 93
3.21 Primitive Variables Versus Reference Variables 95
3.22 Strings 96
3.23 Input—the Scanner Class 100
3.24 Simple File Input for Repetitive Testing During Program Development 105
3.25 GUI Track: Input and Output with Dialog Boxes (Optional) 107
CHAPTER 4
CHAPTER 5
Using Prebuilt Methods 170
5.1 Introduction 170
5.2 The API Library 171
5.3 Math Class 177
5.4 Wrapper Classes for Primitive Types 182
5.5 Character Class 186
5.6 String Methods 188
5.7 Formatted Output with the printf> Method 194
5.8 Problem Solving with Random Numbers (Optional) 199
5.9 GUI Track: Covering an Image with a Tinted Pane (Optional) 203
Interlude 213
Multiple-Method Programs in a Non-Object-Oriented Environment 213
GUI Track: Multiple-Method Program That Uses StackPane and Group to
Display Images, Rectangles, Lines, an Oval, and Text (Optional) 216
CHAPTER 6
CHAPTER 7
CHAPTER 8
CHAPTER 9
Arrays 384
9.1 Introduction 385
9.2 Array Basics 385
9.3 Array Declaration and Creation 387
9.4 Array length Property and Partially Filled Arrays 391
9.5 Copying an Array 393
9.6 Problem Solving with Array Case Studies 397
9.7 Searching an Array 403
9.8 Sorting an Array 408
9.9 Two-Dimensional Arrays 412
9.10 Arrays of Objects 418
9.11 For-Each Loops 425
CHAPTER 10
CHAPTER 11
Recursion 489
11.1 Introduction 490
11.2 Guidelines for Writing a Recursive Method 491
11.3 A Recursive Factorial Method 492
11.4 Comparison of Recursive and Iterative Solutions 496
11.5 Recursive Method Evaluation Practice 500
11.6 Binary Search 503
11.7 Merge Sort 506
11.8 Towers of Hanoi 510
11.9 Problem Solving with Performance Analysis 514
11.10 GUI Track: Drawing Trees with a Fractal Algorithm (Optional) 517
CHAPTER 12
Type Details and Alternative Coding Mechanisms 530
12.1 Introduction 531
12.2 Integer Types and Floating-Point Types 532
12.3 char Type and the ASCII Character Set 536
12.4 Type Conversions 538
12.5 Prefix/Postfix Modes for Increment/ Decrement Operators 541
12.6 Embedded Assignments 544
12.7 Conditional Operator Expressions 546
12.8 Expression Evaluation Review 547
12.9 Short-Circuit Evaluation 551
12.10 Empty Statement 552
12.11 Using break to Exit from a Loop 554 Page viii
12.12 for Loop Header Details 555
12.13 Enumerated Types 557
12.14 forEach Method, Lambda Expressions, Method References, and Streams 564
12.15 Hexadecimal, Octal, and Binary Numbers 573
12.16 GUI Track: Unicode (Optional) 574
12.17 Introduction to GridWorld Case Study (Optional) 579
CHAPTER 13
CHAPTER 15
CHAPTER 16
Files, Buffers, Channels, and Paths 735
16.1 Introduction 736
16.2 Simple Text-File Example: HTML File Generator 737
16.3 A Website Reader 741
16.4 Object File I/O 743
16.5 Character Sets and File-Access Options 748
16.6 Buffered Text File I/O 749
16.7 Primitive Buffers with Random Access 752
16.8 Channel I/O and Memory-Mapped Files 760
16.9 Path, Whole-File, and Directory Operations 767
16.10 Walking a Directory Tree 769 Page ix
16.11 GUI Track: Final Iteration of Problem Solving with CRC Cards (Optional) 775
CHAPTER 17
CHAPTER 18
GUI Programming—Layout Panes 849
18.1 Introduction 849
18.2 Layout Panes 851
18.3 FlowPane and GridPane—Competing Layout Philosophies 853
18.4 VBox Program with Two Stages and an Image File 858
18.5 BorderPane 867
18.6 TilePane and TextFlow Containers 872
18.7 TicTacToe Program 878
18.8 Embedded Panes, HBox, and MathCalculator Program 882
18.9 Plain Pane Container and Component Positioning 889
CHAPTER 19
Appendices
Appendix 1 ASCII Character Set 943
Appendix 2 Operator Precedence 945
Appendix 3 Java Keywords and Other Reserved Words 947
Appendix 4 Packages and Modules 951
Appendix 5 Java Coding-Style Conventions 963
Appendix 6 Javadoc with Tags 975
Appendix 7 UML Diagrams 980
Appendix 8 Number Systems and Conversions Between Them 986
Additional Online Material
Chapter S6 Writing Methods in a Non-Object-Oriented Environment
Chapter S9 Arrays in a Non-Object-Oriented Environment
Chapter S17 GUI Programming Basics (with Swing and AWT)
Chapter S18 GUI Programming—Component Layout, Additional GUI
Components (with Swing and AWT)
Appendix 9 Multithreading
Index 990
Page x
Preface
In this book, we lead you on a journey into the fun and exciting world of computer
programming. Throughout your journey, we’ll provide you with lots of problem-solving
practice. After all, good programmers need to be good problem solvers. We’ll show you how
to implement your problem solutions with Java programs. We provide a plethora of
examples, some short and focused on a single concept, some longer and more “real world.”
We present the material in a conversational, easy-to-follow manner aimed at making your
journey a pleasant one. When you’re done with the book, you should be a proficient Java
programmer.
Our textbook targets a wide range of readers. Primarily, it targets students in a standard
college-level “Introduction to Programming” course or course sequence where no
prerequisite programming experience is assumed. We have included the topics recommended
by the College Board for high school students studying for advanced placement (AP) in
computer science. So this text should be good for those students as well.
In addition to targeting students with no prerequisite programming experience, our
textbook targets industry practitioners and college-level students who have some
programming experience and want to learn Java. This second set of readers can skip the early
chapters on general programming concepts and focus on the features of Java that differ from
the languages that they already know. In particular, because C++ and Java are similar, readers
with a C++ background should be able to cover the textbook in a single three-credit-hour
course. (But we should reiterate for those of you with no programming experience:
No prerequisite programming experience is required in order to use this text.)
Finally, our textbook targets those who are learning Java on their own, outside of a
classroom environment. This third set of readers should read the entire textbook at a pace
determined on a case-by-case basis.
The changes in this edition are big and small. Big changes include new chapters, reorganized
chapter sections, new programming constructs, new program examples, and new exercises.
Smaller changes include updating explanations and anecdotes. We’ve combed the entire book
for opportunities to improve the book’s clarity and readability. The following list highlights
the more significant changes that we’ve made to this edition.
• Introductory Chapter
To keep up with the computer industry’s growth, we’ve made quite a few changes to
Chapter 1, such as updating the information in the computer hardware and Java history
sections.
• Switching Constructs
Java 12 and Java 13 made improvements to the venerable switch statement, and this
edition describes those improvements. We use the new switching techniques (multiple
comma-separated case constants and no break statements) for programs throughout the
book. And we use switch statements versus switch expressions according to what the
problem calls for. If you’re a fan of the old-style switch statement, no worries, we
provide a description early on which will help you with legacy code.
• Local Variable Type Inferencing
Java 10 introduced the ability to use var as a type (rather than int, double, etc.) for a
local variable declaration where the declaration is part of an initialization. We describe
the new syntax, but for self-documentation reasons, we stick with traditional explicit
type declarations for the most part.
• Name Change for Static Variables and Static Methods Page xi
The powers that be (the Oracle documentation folks) now use the terms static variable
and static method for what used to be known as class variable and class method, so
we’ve updated accordingly.
• Miscellaneous Java API Library Updates
With the new Java releases since the second edition, there have been quite a few updates
to the Java API library. We’ve updated our discussions and programs with new API
method and constructor calls when appropriate. Most of our new API content can be
found in our GUI coverage, but there are other API changes sprinkled throughout the
book. For example, with Java’s deprecation of the wrapper class constructors, we’ve
refactored our programs to rely on the wrapper classes’ valueOf methods.
• New Section—forEach Method and Streams
We introduce the forEach method as a simple alternative to the for-each loop in the
context of an ArrayList. We then use the forEach method in the context of streams,
where it really shines. We describe streams in depth, with their exciting potential to take
advantage of parallel processing to improve a program’s efficiency.
• Lambda Expressions and Method References
Lambda expressions and method references are techniques that allow you to implement
the functionality of a method so you can use it as an argument in a method call. We first
present lambda expressions and method references as arguments for a forEach method
call. Later, we use lambda expressions and method references extensively to help with
the GUI programs.
• Interfaces with Static Methods and Default Methods
We’ve rewritten Chapter 14’s section on interfaces to include a discussion of static
methods and default methods. Oracle added them to interfaces because they support an
interface’s ability to implement multiple inheritance effectively.
• End-of-Chapter GUI Sections
We’ve rewritten all of our end-of-chapter GUI sections to take advantage of Java’s
newer GUI constructs.
• Three New Chapters—JavaFX
In this book’s second edition, we used the AWT and Swing platforms for our two GUI
chapters. This third edition moves those chapters to the book’s website. We provide
three new chapters in the main body of the book that describe GUI programming using
the JavaFX platform. As part of that presentation, you’ll learn how to format your
programs using JavaFX CSS properties.
• New Appendix—Modules
In Appendix 4, we introduce modules, which allow you to group together packages.
Modules make it easier to organize and share classes for different programming needs.
They are used to facilitate the configuration of Java software for diverse hardware and
software platforms.
• New Exercises
We have substantially changed most of the exercises and altered almost all of them in
some way. As before, we provide exercise solutions on the password-protected
instructor’s portion of the book’s website.
Page xii
Problem-Solving Sections
We often address problem solving (algorithm development and program design) in the
natural flow of explaining concepts. But we also cover problem solving in sections that are
wholly devoted to it. In each problem-solving section, we present a situation that contains an
unresolved problem. In coming up with a solution for the problem, we try to mimic the real-
world problem-solving experience by using an iterative design strategy. We present a first-cut
solution, analyze the solution, and then discuss possible improvements to it. We use a
conversational trial-and-error format (e.g., “What type of layout manager should we use? We
first tried the GridLayout manager. That works OK, but not great. Let’s now try the
BorderLayout manager.”). This casual tone sets the student at ease by conveying the message
Random documents with unrelated
content Scribd suggests to you:
Stuart, D., I. 406, 427
Suicide, I. 317
Sully, J., I. 191; II. 79, 221, 272, 281, 322, 425
Tactile centre, I. 58
Tedium, I. 626
Thermometry, cerebral, I. 99
Thomson, Allen, I. 84
Tyndall, I. 147-8
Ueberweg, I. 187
Valentin, I. 557
Vintschgau, I. 95-6
Vision with head upside down, II. 213
Vulpian, I. 73
Wahle, I. 493
Ward, J., I. 162, 454, 548, 562, 629, 633; II. 282
Warren, J. W., I. 97
Wayland, I. 347
Wilbrand, I. 50-1
1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside
the United States, check the laws of your country in addition to
the terms of this agreement before downloading, copying,
displaying, performing, distributing or creating derivative works
based on this work or any other Project Gutenberg™ work. The
Foundation makes no representations concerning the copyright
status of any work in any country other than the United States.
1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if
you provide access to or distribute copies of a Project
Gutenberg™ work in a format other than “Plain Vanilla ASCII” or
other format used in the official version posted on the official
Project Gutenberg™ website (www.gutenberg.org), you must,
at no additional cost, fee or expense to the user, provide a copy,
a means of exporting a copy, or a means of obtaining a copy
upon request, of the work in its original “Plain Vanilla ASCII” or
other form. Any alternate format must include the full Project
Gutenberg™ License as specified in paragraph 1.E.1.
• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”
• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.
1.F.
Most people start at our website which has the main PG search
facility: www.gutenberg.org.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookultra.com