Java For Dummies

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

A new edition of the bestselling guide to Java If you want to learn to speak the world’s most popular programming language like a native, Java For Dummies is your ideal companion. With a focus on reusing existing code, it quickly and easily shows you how to create basic Java objects, work with Java classes and methods, understand the value of variables, learn to control program flow with loops or decision-making statements, and so much more! Java is everywhere, runs on almost any computer, and is the engine that drives the coolest applications. Written for anyone who’s ever wanted to tackle programming with Java but never knew quite where to begin, this bestselling guide is your ticket to success! Featuring updates on everything you’ll encounter in Java 9―and brimming with tons of step-by-step instruction―it’s the perfect resource to get you up and running with Java in a jiffy! • Discover the latest features and tools in Java 9 • Learn to combine several smaller programs to create a bigger program • Create basic Java objects and reuse code • Confidently handle exceptions and events If you’re ready to jump into Java, this bestselling guide will help keep your head above water!

Author(s): Barry Burd
Series: For Dummies
Edition: 7
Publisher: John Wiley & Sons, Inc.
Year: 2017

Language: English
Commentary: Vector PDF
Pages: 488
City: Hoboken
Tags: Java programming language; internet programming

Title Page
Copyright Page
Table of Contents
Introduction
How to Use This Book
Conventions Used in This Book
What You Don’t Have to Read
Foolish Assumptions
How This Book Is Organized
Part 1: Getting Started with Java
Part 2: Writing Your Own Java Program
Part 3: Working with the Big Picture: Object-Oriented Programming
Part 4: Smart Java Techniques
Part 5: The Part of Tens
Icons Used in This Book
Beyond the Book
Where to Go from Here
Part 1 Getting Started with Java
Chapter 1 All about Java
What You Can Do with Java
Why You Should Use Java
Getting Perspective: Where Java Fits In
Object-Oriented Programming (OOP)
Object-oriented languages
Objects and their classes
What’s so good about an object-oriented language?
Refining your understanding of classes and objects
What’s Next?
Chapter 2 All about Software
Quick-Start Instructions
What You Install on Your Computer
What is a compiler?
What is a Java Virtual Machine?
Developing software
What is an integrated development environment?
Chapter 3 Using the Basic Building Blocks
Speaking the Java Language
The grammar and the common names
The words in a Java program
Checking Out Java Code for the First Time
Understanding a Simple Java Program
The Java class
The Java method
The main method in a program
How you finally tell the computer to do something
Curly braces
And Now, a Few Comments
Adding comments to your code
What’s Barry’s excuse?
Using comments to experiment with your code
Part 2 Writing Your Own Java Programs
Chapter 4 Making the Most of Variables and Their Values
Varying a Variable
Assignment statements
The types of values that variables may have
Displaying text
Numbers without decimal points
Combining declarations and initializing variables
Experimenting with JShell
What Happened to All the Cool Visual Effects?
The Atoms: Java’s Primitive Types
The char type
The boolean type
The Molecules and Compounds: Reference Types
An Import Declaration
Creating New Values by Applying Operators
Initialize once, assign often
The increment and decrement operators
Assignment operators
Chapter 5 Controlling Program Flow with Decision-Making Statements
Making Decisions (Java if Statements)
Guess the number
She controlled keystrokes from the keyboard
Creating randomness
The if statement
The double equal sign
Brace yourself
Indenting if statements in your code
Elseless in Ifrica
Using Blocks in JShell
Forming Conditions with Comparisons and Logical Operators
Comparing numbers; comparing characters
Comparing objects
Importing everything in one fell swoop
Java’s logical operators
Vive les nuls!
(Conditions in parentheses)
Building a Nest
Choosing among Many Alternatives (Java switch Statements)
Your basic switch statement
To break or not to break
Strings in a switch statement
Chapter 6 Controlling Program Flow with Loops
Repeating Instructions Over and Over Again (Java while Statements)
Repeating a Certain Number of Times (Java for Statements)
The anatomy of a for statement
The world premiere of “Al’s All Wet”
Repeating until You Get What You Want (Java do Statements)
Reading a single character
File handling in Java
Variable declarations and blocks
Part 3 Working with the Big Picture: Object-Oriented Programming
Chapter 7 Thinking in Terms of Classes and Objects
Defining a Class (What It Means to Be an Account)
Declaring variables and creating objects
Initializing a variable
Using an object’s fields
One program; several classes
Public classes
Defining a Method within a Class (Displaying an Account)
An account that displays itself
The display method’s header
Sending Values to and from Methods (Calculating Interest)
Passing a value to a method
Returning a value from the getInterest method
Making Numbers Look Good
Hiding Details with Accessor Methods
Good programming
Public lives and private dreams: Making a field inaccessible
Enforcing rules with accessor methods
Barry’s Own GUI Class
Chapter 8 Saving Time and Money: Reusing Existing Code
Defining a Class (What It Means to Be an Employee)
The last word on employees
Putting your class to good use
Cutting a check
Working with Disk Files (a Brief Detour)
Storing data in a file
Copying and pasting code
Reading from a file
Who moved my file?
Adding directory names to your filenames
Reading a line at a time
Closing the connection to a disk file
Defining Subclasses (What It Means to Be a Full-Time or Part-Time Employee)
Creating a subclass
Creating subclasses is habit-forming
Using Subclasses
Making types match
The second half of the story
Overriding Existing Methods (Changing the Payments for Some Employees)
A Java annotation
Using methods from classes and subclasses
Chapter 9 Constructing New Objects
Defining Constructors (What It Means to Be a Temperature)
What is a temperature?
What is a temperature scale? (Java’s enum type)
Okay, so then what is a temperature?
What you can do with a temperature
Calling new Temperature(32.0): A case study
Some things never change
More Subclasses (Doing Something about the Weather)
Building better temperatures
Constructors for subclasses
Using all this stuff
The default constructor
A Constructor That Does More
Classes and methods from the Java API
The SuppressWarnings annotation
Part 4 Smart Java Techniques
Chapter 10 Putting Variables and Methods Where They Belong
Defining a Class (What It Means to Be a Baseball Player)
Another way to beautify your numbers
Using the Player class
One class; nine objects
Don’t get all GUI on me
Tossing an exception from method to method
Making Static (Finding the Team Average)
Why is there so much static?
Meet the static initializer
Displaying the overall team average
The static keyword is yesterday’s news
Could cause static; handle with care
Experiments with Variables
Putting a variable in its place
Telling a variable where to go
Passing Parameters
Pass by value
Returning a result
Pass by reference
Returning an object from a method
Epilogue
Chapter 11 Using Arrays to Juggle Values
Getting Your Ducks All in a Row
Creating an array in two easy steps
Storing values
Tab stops and other special things
Using an array initializer
Stepping through an array with the enhanced for loop
Searching
Writing to a file
When to close a file
Arrays of Objects
Using the Room class
Yet another way to beautify your numbers
The conditional operator
Command Line Arguments
Using command line arguments in a Java program
Checking for the right number of command line arguments
Chapter 12 Using Collections and Streams (When Arrays Aren’t Good Enough)
Understanding the Limitations of Arrays
Collection Classes to the Rescue
Using an ArrayList
Using generics
Wrapper classes
Testing for the presence of more data
Using an iterator
Java’s many collection classes
Functional Programming
Solving a problem the old-fashioned way
Streams
Lambda expressions
A taxonomy of lambda expressions
Using streams and lambda expressions
Why bother?
Method references
Chapter 13 Looking Good When Things Take Unexpected Turns
Handling Exceptions
The parameter in a catch clause
Exception types
Who’s going to catch the exception?
Catching two or more exceptions at a time
Throwing caution to the wind
Doing useful things
Our friends, the good exceptions
Handle an Exception or Pass the Buck
Finishing the Job with a finally Clause
A try Statement with Resources
Chapter 14 Sharing Names among the Parts of a Java Program
Access Modifiers
Classes, Access, and Multipart Programs
Members versus classes
Access modifiers for members
Putting a drawing on a frame
Directory structure
Making a frame
Sneaking Away from the Original Code
Default access
Crawling back into the package
Protected Access
Subclasses that aren’t in the same package
Classes that aren’t subclasses (but are in the same package)
Access Modifiers for Java Classes
Public classes
Nonpublic classes
Chapter 15 Fancy Reference Types
Java’s Types
The Java Interface
Two interfaces
Implementing interfaces
Putting the pieces together
Abstract Classes
Caring for your pet
Using all your classes
Relax! You’re Not Seeing Double!
Chapter 16 Responding to Keystrokes and Mouse Clicks
Go On . . . Click That Button
Events and event handling
Threads of execution
The keyword this
Inside the actionPerformed method
The serialVersionUID
Responding to Things Other Than Button Clicks
Creating Inner Classes
Chapter 17 Using Java Database Connectivity
Creating a Database and a Table
What happens when you run the code
Using SQL commands
Connecting and disconnecting
Putting Data in the Table
Retrieving Data
Destroying Data
Part 5 The Part of Tens
Chapter 18 Ten Ways to Avoid Mistakes
Putting Capital Letters Where They Belong
Breaking Out of a switch Statement
Comparing Values with a Double Equal Sign
Adding Components to a GUI
Adding Listeners to Handle Events
Defining the Required Constructors
Fixing Non-Static References
Staying within Bounds in an Array
Anticipating Null Pointers
Helping Java Find Its Files
Chapter 19 Ten Websites for Java
This Book’s Website
The Horse’s Mouth
Finding News, Reviews, and Sample Code
Got a Technical Question?
Index
EULA