Title Page....5
Copyright Page....6
Table of Contents....9
Introduction....17
About This Book....17
Foolish Assumptions....18
Icons Used in This Book....19
Beyond the Book....20
Where to Go from Here....20
Part 1 Getting Started with Java....21
Chapter 1 All about Java....23
What You Can Do with Java....24
Why You Should Use Java....25
Gaining Perspective: Where Java Fits In....26
Three Ways to Write Computer Programs....28
A word you can use to impress people....29
Imperative programming....29
Object-oriented programming....30
Functional programming....33
Whats Next?....35
Chapter 2 All about Software....37
Get Ready for Java....37
The Inside Scoop....40
What is a compiler?....41
What is a Java virtual machine?....44
Developing Software....48
Spoiler Alert!....49
Chapter 3 Using the Basic Building Blocks....51
Speaking the Java Language....51
The grammar and the common names....52
The words in a Java program....53
Checking Out Java Code for the First Time....55
Understanding a Simple Java Program....57
The Java method....57
The main method in a program....59
How you finally tell the computer to do something....60
Brace yourself....62
BEGIN THE BEGUINE....64
CAPITAL PAINS....65
STOLEN SEMICOLON....65
MISCELLANEOUS MISCHIEF....65
And Now, a Few Comments....66
Adding comments to your code....67
Whats Barrys excuse?....69
Using comments to experiment with your code....70
Part 2 Writing Your Own Java Programs....73
Chapter 4 Making the Most of Variables and Their Values....75
Varying a Variable....76
Assignment statements....78
The types of values that variables may have....79
How to hold the line....82
Numbers without decimal points....83
Combining declarations and initializing variables....85
Experimenting with JShell....87
The Atoms: Javas Primitive Types....90
The char type....91
The boolean type....94
Creating New Values by Applying Operators....95
Initialize once, assign often....99
The increment and decrement operators....99
Assignment operators....104
The Molecules and Compounds: Reference Types....106
Javas String type....107
Javas Random type....107
Coding with classes, objects, and their methods....108
Reserving a variable name....108
Reserving a variable name....108
Creating an instance and making a variable refer to the instance....109
Calling a method....110
What did he just say?....111
Chapter 5 Controlling the Flow by Making Decisions....113
Making Decisions (Java if Statements)....114
Guess the number....114
She controlled keystrokes from the keyboard....115
Reading double values: a cautionary tale....116
The if statement....117
Equal, equal....118
Brace yourself....119
Your intent to indent....119
Elseless in Helsinki....120
Forming Conditions with Comparisons and Logical Operators....123
Comparing numbers; comparing characters....123
Comparing objects....124
When one line isnt enough....127
Javas logical operators....128
Vive les nuls!....130
(Conditions in parentheses)....132
An import declaration....133
Warning! Explicit content!....136
The Nesting Habits of if Statements....138
Choosing among Many Alternatives....139
Javas glorious switch statement....139
Express yourself....143
Your grandparents switch statement....145
Free fall....146
Chapter 6 Controlling Program Flow with Loops....151
Repeating Instructions Over and Over Again (Java while Statements)....152
Count On Me....155
The anatomy of a for statement....157
The world premiere of Als All Wet....158
You Can Always Get What You Want....161
Who moved my file?....164
Reading a single character....164
On the var side....165
File handling in Java....166
Block on the while side....167
Part 3 Working with the Big Picture: Object-Oriented Programming....171
Chapter 7 The Inside scOOP....173
Defining a Class (What It Means to Be an Account)....174
Declaring variables and creating objects....176
Using an objects fields....177
One program; several classes....178
The road not taken....179
Defining a Method within a Class (Displaying an Account)....180
An account that displays itself....182
The display methods header....184
Sending Values to and from Methods (Calculating Interest)....187
Passing a value to a method....190
Returning a value from the getInterest method....191
Giving Your Numbers a Makeover....193
Hide-and-Seek....196
Good programming....197
Public lives and private dreams: Making a field inaccessible....199
Enforcing rules with accessor methods....201
Streamlining Java....202
Experiments with Variables....206
Putting a variable in its place....207
Telling a variable where to go....209
Passing Parameters....213
Pass by value....213
Returning a result....214
Pass by reference....215
Returning an object from a method....217
A final word....219
Chapter 8 Constructing New Objects....221
Defining Constructors (What It Means to Be a Temperature)....222
What is a temperature?....223
What is a temperature scale? (Javas enum type)....223
Okay, so then what is a temperature?....224
What you can do with a temperature....227
What does a temperature look like?....230
Constructing a temperature; a slow-motion replay....231
The default constructor....233
The Easy Way to Create a Class....236
Constructors dont have to be dull....239
Equality for all!....242
Chapter 9 Piles of Files: Dealing with Information Overload....245
What It Means to Be an Employee....246
Putting your class to good use....248
She reads keystrokes from the keyboard....250
Working with Disk Files....253
Cutting a check....257
Repeat after me....258
Reading from a file....259
Wheres your file?....260
You can decide where to put your file....261
Reading a line at a time....261
Clean up after yourself....263
Chapter 10 Saving Time and Money: Reusing Existing Code....265
Defining Subclasses (What It Means to Be a Full-Time or Part-Time Employee)....266
Creating a subclass....269
Creating subclasses is habit-forming....273
Using Subclasses....274
Making types match....275
The second half of the story....276
Changing the Payments for Only Some of the Employees....278
A Java annotation....279
Using methods from classes and subclasses....280
Yet Another switch....284
Doing Something about the Weather....286
Constructors for subclasses....288
Using all this stuff....289
Constructor madness....290
Part 4 Smart Java Techniques....295
Chapter 11 Putting Variables and Methods Where They Belong....297
Making a Package....298
Package deal....298
Using the Player class....300
Running the code....303
One class; nine objects....304
Some notes on formatting....305
Its All About Access....307
Access for Java modules....308
Access modifiers for classes....309
Public classes....309
Nonpublic classes....310
A word or two about method-local variables....310
Access for members (fields and methods)....311
Members in the same class....311
Members in different classes....311
Making Static (Finding the Team Average)....317
So much static!....319
Meet the compact constructor....319
Displaying the overall team average....320
All about static import....322
All about static references....323
Why static members dont always play well with others....324
Chapter 12 Using Collections and Streams....329
Using an ArrayList....330
A new way to do looping....334
Import a module in one fell swoop....335
Using generics....336
You have options....336
Wrap it up....337
Are we done yet?....339
Once and again....340
Sorting and Searching....340
Another Kind of Collection Class....342
So many collection classes!....344
Functional Programming....345
Problem-solving the old-fashioned way....346
A familiar problem....347
Lambda expressions....348
The interpretation of streams....350
Getting a stream from a collection....352
Filtering the items in a stream....352
Getting a value from each item in a stream....353
Summarizing the items in a stream....353
Why bother?....356
Method references....359
Some black sheep among the lambdas....360
Chapter 13 Using Arrays to Juggle Values....365
Getting Your Ducks All in a Row....365
How to book hotel guests....367
Tab stops and other special things....368
Make life easy for yourself....369
Array versus ArrayList: The Ultimate Showdown....372
Do You Have a Room?....373
Writing to a file....375
What else can go wrong?....376
Array Madness....377
Return to Sanity....379
Arrays of Objects....381
Using the Room class....383
The conditional operator....386
How to Argue with Your Code....387
Settling the argument....388
Checking for the right number of program arguments....390
Chapter 14 Looking Good When Things Take Unexpected Turns....393
Garbage In....394
Making things right....398
The parameter in a catch clause....398
Do it yourself....401
Who will catch the exception?....403
Catching two or more exceptions at a time....410
The Buck Stops Here, Except When It Doesnt....411
Catch it soon....412
Catch it later....414
Checked or unchecked?....416
Try, Try Again!....418
Chapter 15 Fancy Reference Types....423
Javas Types....423
The Java Interface....424
Declaring two interfaces....425
Implementing interfaces....427
Putting the pieces together....429
Abstract Classes....433
Caring for your pet....436
Using all your classes....438
Relax! Youre Not Seeing Double!....440
Chapter 16 Oooey GUI Was a Worm....443
Getting Started with GUI Applications....444
Setting up your computer....444
Installing the JavaFX plug-in....445
Installing Scene Builder....446
Creating a bare-bones JavaFX project....447
Running your bare-bones JavaFX project....450
Adding Stuff to Your JavaFX Project....452
Wheres my Scene Builder application?....452
Building a scene....453
Tweaking some code....456
Running your new project....457
Part 5 The Part of Tens....459
Chapter 17 Ten Packs of Java Websites....461
This Books Website....461
For Business Issues Related to This Book....461
Download the Java Development Kit....462
Your Grandparents Java Download Site....462
The Horses Mouth....462
Join Java User Groups....462
Find the Latest News about Java....462
Find News, Reviews, and Sample Code....463
Got a Technical Question about Anything?....463
Become Involved in the Future of Java....463
Chapter 18 Ten Bits of Advice for New Software Developers....465
How Long Does It Take to Learn Java?....466
Which of Your Books Should I Read?....466
Are Books Other than Yours Good for Learning Java?....466
Which Computer Programming Language(s) Should I Learn?....467
Which Skills Other than Computer Coding Should I Learn?....467
How Should I Continue My Learning as a Software Developer?....468
How Else Should I Continue My Learning as a Developer?....468
How Can I Land a Job Developing Software?....469
I Still Dont Know What to Do with My Life....469
If I Have Other Questions, How Can I Contact You?....470
Index....471
EULA....499
Learn to code with Java and open the gate to a rewarding career
Now in its 9th edition, Java For Dummies gives you the essential tools you need to understand the programming language that 17 million software developers rely on. This beginner-friendly guide simplifies every step of the learning process. You'll learn the basics of Java and jump into writing your own programs. Along the way, you'll gain the skills you need to reuse existing code, create new objects, troubleshoot when things go wrong, and build working programs from the ground up. Java For Dummies will help you become a Java developer, even if you're brand new to the world of coding.
This is the must-have Dummies resource for beginning programmers and students who need a step-by-step guide to getting started with Java. You'll also love this book if you're a seasoned programmer adding another language to your repertoire.