Java All in One For Dummies Fifth Edition Doug Lowe download
Java All in One For Dummies Fifth Edition Doug Lowe download
Lowe download
https://textbookfull.com/product/java-all-in-one-for-dummies-
fifth-edition-doug-lowe/
https://textbookfull.com/product/networking-all-in-one-for-
dummies-sixth-edition-doug-lowe/
https://textbookfull.com/product/networking-all-in-one-for-
dummies-8th-edition-doug-lowe/
https://textbookfull.com/product/networking-all-in-one-for-
dummies-7th-edition-lowe/
https://textbookfull.com/product/pregnancy-all-in-one-for-
dummies-joanne-stone/
Windows 10 All In One For Dummies Leonhard
https://textbookfull.com/product/windows-10-all-in-one-for-
dummies-leonhard/
https://textbookfull.com/product/windows-10-all-in-one-for-
dummies-leonhard-2/
https://textbookfull.com/product/linux-all-in-one-for-dummies-
emmett-a-dulaney/
https://textbookfull.com/product/ebay-business-all-in-one-for-
dummies-marsha-collier/
https://textbookfull.com/product/career-development-all-in-one-
for-dummies-1st-edition-coll/
Java® All-in-One For Dummies®, 5th Edition
Published by: John Wiley & Sons, Inc., 111 River Street,
Hoboken, NJ 07030-5774, www.wiley.com
Copyright © 2017 by John Wiley & Sons, Inc., Hoboken, New
Jersey
Published simultaneously in Canada
No part of this publication may be reproduced, stored in a
retrieval system or transmitted in any form or by any means,
electronic, mechanical, photocopying, recording, scanning or
otherwise, except as permitted under Sections 107 or 108 of the
1976 United States Copyright Act, without the prior written
permission of the Publisher. Requests to the Publisher for
permission should be addressed to the Permissions Department,
John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030,
(201) 748-6011, fax (201) 748-6008, or online at
http://www.wiley.com/go/permissions .
Table of Contents
Cover
Introduction
About This Book
Foolish Assumptions
Icons Used in This Book
Beyond the Book
Where to Go from Here
Book 1: Java Basics
Chapter 1: Welcome to Java
What Is Java, and Why Is It So Great?
Java versus Other Languages
Important Features of the Java Language
On the Downside: Java’s Weaknesses
Java Version Insanity
What’s in a Name?
Chapter 2: Installing and Using Java
Tools
Downloading and Installing the Java Development
Kit
Using Java’s Command-Line Tools
Using Java Documentation
Chapter 3: Working with TextPad
Downloading and Installing TextPad
Editing Source Files
Compiling a Program
Running a Java Program
Book 2: Programming Basics
Chapter 1: Java Programming Basics
Looking at the Infamous Hello, World! Program
Dealing with Keywords
Working with Statements
Working with Blocks
Creating Identifiers
Crafting Comments
Introducing Object-Oriented Programming
Importing Java API Classes
Chapter 2: Working with Variables
and Data Types
Declaring Variables
Initializing Variables
Using Final Variables (Constants)
Working with Primitive Data Types
Working with Strings
Converting and Casting Numeric Data
Thinking Inside the Box
Understanding Scope
Shadowing Variables
Printing Data with System.out
Getting Input with the Scanner Class
Getting Input with the JOptionPane Class
Using enum to Create Your Own Data Types
Chapter 3: Working with Numbers
and Expressions
Working with Arithmetic Operators
Dividing Integers
Combining Operators
Using the Unary Plus and Minus Operators
Using Increment and Decrement Operators
Using the Assignment Operator
Using Compound Assignment Operators
Using the Math Class
Formatting Numbers
Recognizing Weird Things about Java Math
Chapter 4: Making Choices
Using Simple Boolean Expressions
Using if Statements
Using Mr. Spock’s Favorite Operators (Logical
Ones, of Course)
Using the Conditional Operator
Comparing Strings
Chapter 5: Going Around in Circles
(Or, Using Loops)
Using Your Basic while Loop
Breaking Out of a Loop
Looping Forever
Using the continue Statement
Running do-while Loops
Validating Input from the User
Using the Famous for Loop
Nesting Your Loops
Chapter 6: Pulling a Switcheroo
Battling else-if Monstrosities
Using the switch Statement
Creating Character Cases
Intentionally Leaving Out a Break Statement
Switching with Strings
Chapter 7: Adding Some Methods to
Your Madness
The Joy of Methods
The Basics of Making Methods
Methods That Return Values
Methods That Take Parameters
Chapter 8: Handling Exceptions
Understanding Exceptions
Catching Exceptions
Handling Exceptions with a Preemptive Strike
Catching All Exceptions at Once
Displaying the Exception Message
Using a finally Block
Handling Checked Exceptions
Throwing Your Own Exceptions
Catching Multiple Exceptions
Book 3: Object-Oriented Programming
Chapter 1: Understanding Object-
Oriented Programming
What Is Object-Oriented Programming?
Understanding Objects
Understanding the Life Cycle of an Object
Working with Related Classes
Designing a Program with Objects
Diagramming Classes with UML
Chapter 2: Making Your Own Classes
Declaring a Class
Working with Members
Using Getters and Setters
Overloading Methods
Creating Constructors
Finding More Uses for the this Keyword
Using Initializers
Chapter 3: Working with Statics
Understanding Static Fields and Methods
Working with Static Fields
Using Static Methods
Counting Instances
Preventing Instances
Using Static Initializers
Chapter 4: Using Subclasses and
Inheritance
Introducing Inheritance
Creating Subclasses
Overriding Methods
Protecting Your Members
Using this and super in Your Subclasses
Understanding Inheritance and Constructors
Using final
Casting Up and Down
Determining an Object’s Type
Poly What?
Creating Custom Exceptions
Chapter 5: Using Abstract Classes
and Interfaces
Using Abstract Classes
Using Interfaces
More Things You Can Do with Interfaces
Using Default Methods
Chapter 6: Using the Object and Class
Classes
The Mother of All Classes: Object
The toString Method
The equals Method
The clone Method
The Class Class
Chapter 7: Using Inner Classes,
Anonymous Classes, and Lambda
Expressions
Declaring Inner Classes
Using Static Inner Classes
Using Anonymous Inner Classes
Using Lambda Expressions
Chapter 8: Working with Packages
and the New Java Module System
Working with Packages
Putting Your Classes in a JAR File
Using JavaDoc to Document Your Classes
Using the Java Module System
Book 4: Strings, Arrays, and Collections
Chapter 1: Working with Strings
Reviewing Strings
Using the String Class
Using the StringBuilder and StringBuffer Classes
Using the CharSequence Interface
Chapter 2: Using Arrays
Understanding Arrays
Creating Arrays
Initializing an Array
Using for Loops with Arrays
Solving Homework Problems with Arrays
Using the Enhanced for Loop
Using Arrays with Methods
Using Two-Dimensional Arrays
Working with a Fun but Complicated Example: A
Chessboard
Using the Arrays Class
Chapter 3: Using the ArrayList Class
Understanding the ArrayList Class
Creating an ArrayList Object
Adding Elements
Accessing Elements
Printing an ArrayList
Using an Iterator
Updating Elements
Deleting Elements
Chapter 4: Using the LinkedList Class
Understanding the LinkedList Class
Creating a LinkedList
Adding Items to a LinkedList
Retrieving Items from a LinkedList
Updating LinkedList Items
Removing LinkedList Items
Chapter 5: Creating Generic
Collection Classes
Why Generics?
Creating a Generic Class
A Generic Stack Class
Using Wildcard-Type Parameters
A Generic Queue Class
Using the Diamond Operator
Chapter 6: Using Bulk Data
Operations with Collections
Looking At a Basic Bulk Data Operation
Looking Closer at the Stream Interface
Using Parallel Streams
Book 5: Programming Techniques
Chapter 1: Programming Threads
Understanding Threads
Creating a Thread
Implementing the Runnable Interface
Creating Threads That Work Together
Using an Executor
Synchronizing Methods
Creating a Lock
Coping with Threadus Interruptus
Chapter 2: Using Regular Expressions
Creating a Program for Experimenting with Regular
Expressions
Performing Basic Character Matching
Using Regular Expressions in Java Programs
Chapter 3: Using Recursion
Calculating the Classic Factorial Example
Displaying Directories
Writing Your Own Sorting Routine
Chapter 4: Working with Dates and
Times
Pondering How Time is Represented
Picking the Right Date and Time Class for Your
Application
Using the now Method to Create a Date-Time
Object
Using the parse Method to Create a Date-Time
Object
Using the of Method to Create a Date-Time Object
Looking Closer at the LocalDate Class
Extracting Information About a Date
Comparing Dates
Calculating with Dates
Formatting Dates
Looking at a Fun Birthday Calculator
Book 6: JavaFX
Chapter 1: Hello, JavaFX!
Perusing the Possibilities of JavaFX
Looking at a Simple JavaFX Program
Importing JavaFX Packages
Extending the Application Class
Launching the Application
Overriding the start Method
Creating a Button
Handling an Action Event
Creating a Layout Pane
Making a Scene
Setting the Stage
Examining the Click Counter Program
Chapter 2: Handling Events
Examining Events
Handling Events
Implementing the EventHandler Interface
Handling Events with Inner Classes
Handling Events with Anonymous Inner Classes
Using Lambda Expressions to Handle Events
Chapter 3: Setting the Stage and
Scene Layout
Examining the Stage Class
Examining the Scene Class
Switching Scenes
Creating an Alert Box
Exit, Stage Right
Chapter 4: Using Layout Panes to
Arrange Your Scenes
Working with Layout Panes
Using the HBox Layout
Spacing Things Out
Adding Space with Margins
Adding Space by Growing Nodes
Using the VBox Layout
Aligning Nodes in a Layout Pane
Making Nodes the Same Width
Using the Flow Layout
Using the Border Layout
Using the GridPane Layout
Chapter 5: Getting Input from the
User
Using Text Fields
Validating Numeric Data
Using Check Boxes
Using Radio Buttons
Looking at a Pizza Order Application
Chapter 6: Choosing from a List
Using Choice Boxes
Working with Observable Lists
Listening for Selection Changes
Using Combo Boxes
Using List Views
Using Tree Views
Book 7: Web Programming
Chapter 1: Using Java Web Start
Looking at a Simple JavaFX Program
Understanding Java Web Start
Creating a JNLP File
Creating an HTML File to Launch a Java
Application
Uploading the Java Web Start Files to Your Web
Server
Launching the ClickMe Application Using Java Web
Start
Creating an Exception to Allow Java Web Start
Applications to Run
Chapter 2: Creating Servlets
Understanding Servlets
Using Tomcat
Creating a Simple Servlet
Running a Servlet
Improving the HelloWorld Servlet
Getting Input from the User
Using Classes in a Servlet
Chapter 3: Using JavaServer Pages
Understanding JavaServer Pages
Using Page Directives
Using Expressions
Using Scriptlets
Using Declarations
Using Classes
Chapter 4: Using JavaBeans
Getting to Know JavaBeans
Looking Over a Sample Bean
Using Beans with JSP Pages
Scoping Your Beans
Book 8: Files and Databases
Chapter 1: Working with Files
Using the File Class
Using Command-Line Parameters
Choosing Files in a Swing Application
Using Path Objects
Using a File Visitor to Walk a File Tree
Chapter 2: Working with File Streams
Understanding Streams
Reading Character Streams
Writing Character Streams
Reading Binary Streams
Writing Binary Streams
Chapter 3: Database for $100, Please
Defining a Relational Database
Understanding (and Pronouncing) SQL
Introducing SQL Statements
Creating a SQL Database
Querying a Database
Updating and Deleting Rows
Chapter 4: Using JDBC to Connect to
a Database
Setting Up a Driver
Connecting to a Database
Querying a Database
Updating SQL Data
Using an Updatable RowSet Object
Chapter 5: Working with XML
Defining XML
Using a DTD
Processing XML in Two Ways: DOM and SAX
Reading a DOM Document
Reading DOM Nodes
Putting It All Together: A Program That Lists
Movies
About the Author
Advertisement Page
Connect with Dummies
End User License Agreement
Guide
Cover
Table of Contents
Begin Reading
Introduction
Welcome to Java All-in-One For Dummies, 5th Edition — the one
Java book that’s designed to replace an entire shelf full of the
dull, tedious titles you’d otherwise have to buy. This book
contains all the basic information you need to know to get going
with Java programming, starting with writing statements and
using variables and ending with techniques for writing programs
that use animation and play games. Along the way, you find
plenty of not-so-basic information about programming user
interfaces, working with classes and objects, creating web
applications, and dealing with files and databases.
You can (and probably should, eventually) buy separate books on
each of these topics. It won’t take long before your bookshelf is
bulging with 10,000 or more pages of detailed information about
every imaginable nuance of Java programming. But before you’re
ready to tackle each of those topics in depth, you need to get a
bird’s-eye picture. That’s what this book is about.
And if you already own 10,000 pages or more of Java information,
you may be overwhelmed by the amount of detail and wonder,
“Do I really need to read 1,200 pages about JSP just to create a
simple web page? And do I really need a six-pound book on
JavaFX?” Truth is, most 1,200-page programming books have
about 200 pages of really useful information — the kind you use
every day — and about 1,000 pages of excruciating details that
apply mostly if you’re writing guidance-control programs for
nuclear missiles or trading systems for the New York Stock
Exchange.
The basic idea here is that I’ve tried to wring out the 100-or-so
most useful pages of information on these different Java
programming topics: setup and configuration, basic programming,
object-oriented programming, programming techniques, JavaFX,
file and database programming, web programming, and animation
and game programming. Thus you get a nice, trim book.
So whether you’re just getting started with Java programming or
you’re a seasoned pro, you’ve found the right book.
About This Book
Java All-in-One For Dummies, 5th Edition, is a reference for all the
great things (and maybe a few not-so-great things) that you may
need to know when you’re writing Java programs. You can, of
course, buy a huge 1,200-page book on each of the programming
topics covered in this book. But then, who would carry them
home from the bookstore for you? And where would you find the
shelf space to store them? And when will you find the time to
read them?
In this book, all the information you need is conveniently
packaged for you in-between one set of covers. And all of the
information is current for the newest release of Java, known as
JDK 9. This book doesn’t pretend to be a comprehensive
reference for every detail on every possible topic related to Java
programming. Instead, it shows you how to get up and running
fast so that you have more time to do the things you really want
to do. Designed using the easy-to-follow For Dummies format,
this book helps you get the information you need without laboring
to find it.
Java All-in-One For Dummies, 5th Edition, is a big book made up
of nine smaller books — minibooks, if you will. Each of these
minibooks covers the basics of one key element of programming,
such as installing Java and compiling and running programs, or
using basic Java statements, or using JavaFX to write GUI
applications.
Whenever one big thing is made up of several smaller things,
confusion is always a possibility. That’s why this book has multiple
access points. At the beginning is a detailed table of contents that
covers the entire book. Then each minibook begins with a
minitable of contents that shows you at a miniglance what
chapters are included in that minibook. Useful running heads
appear at the top of each page to point out the topic discussed on
that page. And handy thumbtabs run down the side of the pages
to help you find each minibook quickly. Finally, a comprehensive
index lets you find information anywhere in the entire book.
Foolish Assumptions
You and I have never met, so it is difficult for me to make any
assumptions about why you are interested in this book. However,
let’s start with a few basic assumptions:
Plague
Week ending
deaths
May 14 59
21 55
28 99
June 4 122
11 99
18 162
25 133
July 2 172
9 184
16 212
23 270
30 366
Aug. 7 337
14 422
21 346
28 246
Sept. 4 520
11 325
To end of Dec. 908
Total to 31st Dec. 5027
Buried of
Christened Buried in all plague
Dec. 24 231 170 0
31 195 174 0
1636
Jan. 7 217 189 0
14 242 174 0
21 220 190 0
28 214 171 0
Feb. 4 227 183 0
11 234 160 0
18 207 203 0
25 198 238 0
Mar. 3 221 198 0
10 231 194 0
17 244 187 0
24 215 177 0
31 193 196 0
Apr. 7 202 199 2
14 221 205 4
21 202 205 7
28 271 210 4
May 5 197 206 4
12 199 254 41
19 171 244 22
26 160 263 38
June 2 189 276 51
9 153 275 64
16 145 325 86
23 149 257 65
30 141 273 82
July 7 152 265 64
14 142 298 86
21 146 350 108
28 183 365 136
Aug. 4 152 394 181
11 166 465 244
18 167 546 284
25 161 690 380
Sept. 1 163 835 536
8 153 921 567
15 166 1106 728
22 172 1018 645
29 168 1211 796
Oct. 6 170 1195 790
13 164 1117 682
20 174 855 476
27 133 779 404
Nov. 3 153 1156 755
10 164 966 635
17 143 827 512
24 162 747 408
Dec. 1 168 550 290
8 175 335 143
15 134 324 79
9,522 23,359 10,400
The parishes chiefly affected were the same as in 1625 and 1603.
Stepney is still wanting from the general bill; but after 1636 it was
included therein, along with Newington, Lambeth, Westminster,
Islington and Hackney. These omitted parishes doubtless contributed
largely, Stepney in particular, so that the total of plague-deaths
would have to be increased by perhaps two thousand. The following
parishes had the severest mortalities:
Fever in London.
There ought to have been no difficulty in answering the question.
The causes of death in the metropolis had been assigned in the
books kept at Parish Clerks’ Hall since 1604, and had been printed
since 1629. The printed series was in the hands of Graunt, from
1629 down to the date of his writing, January 1662; and he did
abstract the deaths under each head of disease and casualty from
1629 to 1636 inclusive, and again from 1647 to 1661; but the ten
years from 1637 to 1646 inclusive, he omitted as presenting nothing
of importance and as being “inconsistent with the capacity” of his
sheet of paper[1057]. All the original documents prior to 1658 appear
to have been lost in the fire of 1666, so that Graunt’s omission
cannot now be made good. One could wish that the worthy citizen
had made no difficulty about the size of his paper. The omitted years
are not only those of great political revolution, which may have had
an effect upon the public health, but they are of special interest for
the beginning of that great period of fever and smallpox in London
which continued all through the 18th century.
The following section of London mortality, down to the end of our
present period, will show, by reference to the total deaths, how
important the omitted years are for the epidemiological history.
Total
Year Plague Fever Smallpox deaths
1629 0 956 72 8771
1630 1317 1091 40 10554
31 274 1115 58 8562
32 8 1108 531 9535
33 0 953 72 8393
34 1 1279 1354 10400
35 0 1622 293 10651
36 10400 2360 127 23359
37 3082 — — 11763
38 363 — — 13624
39 314 — — 9862
1640 1450 — — 12771
41 1375 — — 13142
42 1274 — — 13273
43 996 — — 13212
44 1492 — — 10933
45 1871 — — 11479
46 2365 — — 12780
47 3597 1260 139 14059
48 611 884 401 9894
49 67 751 1190 10566
1650 15 970 184 8754
51 23 1038 525 10827
52 16 1212 1279 12569
53 6 282 139 10087
54 16 1371 832 13247
55 9 689 1294 11357
56 6 875 823 13921
57 4 999 835 12434
58 14 1800 409 14993
59 36 2303 1523 14756
1660 13 2148 354 12681
61 20 3490 1246 16665
62 12 2601 768 13664
63 9 2107 411 12741
64 5 2258 1233 15453
65 68596 5257 655 97306
1666 1998 741 38 12738
The year 1638, and the four successive years 1640-43, have
exceptional mortalities, which plague alone can by no means
account for. In one of those years, 1641, we know that smallpox was
rife, along with plague, in the autumn; in the third week of August
there were 118 deaths from smallpox (133 from plague), and in the
second week of September 101 from smallpox (185 from plague),
the plague continuing at even higher figures all through September
and October, while smallpox ceases to be mentioned in the letters of
the time[1058]. According to earlier and later experience, the
epidemic of smallpox would have been followed by a quiet interval of
that disease; so that the high mortality, beyond what plague could
account for, would have been due to some other epidemic type.
There is little doubt that that type was fever, less heard of in letters
of the society people because it was, in its steady prevalence from
year to year, an infection of the crowded quarters of the poor.
We begin about this period to find fever, or typhus fever, taking that
place in the medical history of England which it continued to hold
down to the generation before our own. What remains of the history
of plague until its extinction in 1665-66, is so closely interwoven with
the history of malignant fever, that it will be more convenient to
carry the latter on side by side with it instead of in a separate
chapter.
The first medical essay upon the malignant fever which got the
name of typhus at the beginning of the 19th century, was that of a
physician, Sir Edward Greaves, published at Oxford in 1643 in
connexion with the sickness in that city while the king and the
Royalist army lay there, and with the sickness in the Parliamentary
army of the earl of Essex which lay at Reading. Greaves describes
the unmistakable characters of spotted fever or typhus, and calls it,
in his title “Morbus Epidemicus Anni 1643, or the New Disease.” In
his text he speaks of “this so frequently termed the New Disease.”
The name of “New Disease” was used also for influenza; but there
can be no doubt that typhus did become common in England during
the Civil Wars, between the Royalists and the Parliamentarians,
which were the first and also the only sieges and campaigns on
English soil that really touched the life of the nation.
The continent of Europe had been familiar with the same type of
fever ever since the beginning of the 16th century, now in Italy, now
in Spain, another time in the Low Countries, or in Hungary, or in
Germany in the Thirty Years’ War. Greaves, our first writer on
epidemic typhus, had been preceded a whole century by Fracastori,
whose description of the fever at Verona in 1505 is perhaps the first
account of epidemic sickness free from subservience to ancient or
medieval authority, and based upon direct observations made in
modern Europe. At the same time typhus or spotted fever was not
new to England in 1643. There is always the difficulty whether some
epidemics of fever should be called influenza or typhus; but the
fever of the Black Assizes, as well as the standing “sickness of the
house,” was certainly typhus, and so probably was the “new disease”
in 1612.
The history of fever in England has been partly traced in the chapter
on gaol-fevers in the Tudor period and on the Protean “hot agues,”
“new sickness,” “strange fevers” or influenzas of 1540, 1557-8 and
1580. At a much earlier period, fevers of the same type (with
dysenteries, lienteries, and pestilent sore throats) have been
described, with whatever details there are, in connexion with the
periodic famines, especially since the Conquest. But we are now
come to a time in the history when typhus fevers appeared in the
country unconnected with gaols or with famines. We are come,
indeed, to the new era of epidemics, which is revealed more clearly
after the plague was extinguished for good, but was really
concurrent with the last half-century of plague, preparing, as it were,
to succeed the long reign of that infection. The Civil Wars may be
admitted to have given the new types of sickness an impulse, but
the wars did not originate them, nor did they serve in any way to
establish them as the predominant forms of epidemic sickness for
nearly two centuries. Whatever it was in the condition of England
that favoured the prevalence of fevers, fluxes, and smallpox, that
factor was beginning to make itself felt shortly after the Tudor period
ended: it continued in operation through all political changes of
Restoration, Revolution, and Georgian rule; and if the conditions at
length changed, largely for the better so far as the adult population
is concerned, and for the better even as regards infancy, there has
followed the “nova cohors febrium” of our own time, appropriate to
its own state of society, as was the old troop before it. This theme is
really the subject with which a new volume should open; but as the
plague-period overlaps its successor the fever-period by half a
century, and as one must pay heed to the chronology, it remains to
insert some facts about fevers in this place.
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.
textbookfull.com