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"

Learn to write practical, reusable code with the straightforward tutorials and tips in the newest edition of this For Dummies bestseller Do you speak Java? No, we’re not talking about your morning cup ‘o joe. We mean the world’s most popular programming language that runs on almost any computer! If you’re looking to get started—or up your game—with Java, then Java For Dummies is the guide you need. In this book, you’ll: Take control of your program flow Program with classes, objects, and methods Use Java's functional programming features Explore Java 17, the latest long-term support release This up-to-date handbook covers the latest developments in Java, including the new ‘switch’ statement syntax. So, if you’re ready to dive into one of the most practical (and coolest!) programming languages around, it’s time you picked up Java For Dummies. --------------- Learning Java® is smooth sailing with Dummies The bestselling guide to the Java® programming language is back. Java For Dummies is your need-to-read guide for mastering this essential programming language. Even if you aren’t studying Java on the island of Java, you’ll feel like you’re on vacation, with easy-to-understand explanations that make learning easy, for beginners and experienced coders alike. Start with the essential building blocks and bushwhack your way through writing programs that work. Pick up some fancy tips and techniques along the way, and you’ll soon be a native of Java land. ------------------ Inside… Develop good software Control program flow Create objects and classes Use arrays and collections Respond to button clicks Connect to a database Download the book’s sample code Get practice with additional exercises -------------------- About the Author Dr. Barry Burd holds an M.S. in Computer Science from Rutgers University and a Ph.D. in Mathematics from the University of Illinois. Barry is also the author of Beginning Programming with Java For Dummies, Java for Android For Dummies, and Flutter For Dummies.

Author(s): Barry Burd
Edition: 8
Publisher: Wiley
Year: 2022

Language: English
Pages: 512
Tags: java17 java openjdk jdk web dbms jdbc microservices

Title Page
Copyright Page
Table of Contents
Introduction
About This Book
Foolish Assumptions
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
Gaining Perspective: Where Java Fits In
Object-Oriented Programming (OOP)
Object-oriented languages
Objects and their classes
What’s so great about an object-oriented language?
Objects and classes are everywhere
What’s Next?
Chapter 2 All about Software
Get Ready for Java
The Inside Scoop
What is a compiler?
What is a Java virtual machine?
Developing Software
Spoiler Alert!
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
Brace yourself
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
How to hold the line
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
Equal, equal
Brace yourself
Your intent to indent
Elseless in Helsinki
Using Blocks in JShell
Forming Conditions with Comparisons and Logical Operators
Comparing numbers; comparing characters
Comparing objects
Look!
Java’s logical operators
Vive les nuls!
(Conditions in parentheses)
The Nesting Habits of if Statements
Choosing among Many Alternatives
Java’s glorious switch statement
A switch in time saves 14
Your grandparents’ switch statement
Free fall
Chapter 6 Controlling Program Flow with Loops
Repeating Instructions Over and Over Again (Java while Statements)
Count On Me
The anatomy of a for statement
The world premiere of “Al’s All Wet”
You Can Always Get What You Want
The root of the matter
Reading a single character
File handling in Java
Block on the while side
Part 3 Working with the Big Picture: Object-Oriented Programming
Chapter 7 The Inside scOOP
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
Declaring a public class
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
Giving Your Numbers a Makeover
Hide-and-Seek
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
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
Repeat after me
Reading from a file
Who moved my file?
You moved your file!
Reading a line at a time
Clean up after yourself
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
Changing the Payments for Only Some of the 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
Constructing a temperature; a slow-motion replay
Some things never change
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
Live dangerously
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
Some facts about potatoes
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
How to book hotel guests
Tab stops and other special things
Make life easy for yourself
Stepping through an array with the enhanced for loop
Do you have a room?
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
How to Argue with Your Code
Settling the argument
Checking for the right number of program arguments
Chapter 12 Using Collections and Streams (When Arrays Aren’t Good Enough)
Arrays Have Limitations
Collection Classes to the Rescue
Using an ArrayList
Using generics
Wrap it up
Are we done yet?
Once and again
So many collection classes!
Functional Programming
Problem-solving the old-fashioned way
Lambda expressions
A black sheep among the lambdas
A taxonomy of lambda expressions
The interpretation of streams
Why bother?
Method references
Chapter 13 Looking Good When Things Take Unexpected Turns
Garbage In
The parameter in a catch clause
Do it yourself
Who will catch the exception?
Catching two or more exceptions at a time
The Buck Stops Here, Except When It Doesn’t
Catch it soon
Catch it later
Checked or unchecked?
Try, Try Again!
Chapter 14 Sharing Names among the Parts of a Java Program
Access Modifiers
Classes and Their Members
Public and Private Access for Members
Drawing on a frame
Putting a package in its place
Making a frame
Default Access for Members
Switching to Default access
Accessing default members within a package
Protected Access for Members
A class in one package and a subclass in another
Two classes in the same package
Access Modifiers for Java Classes
Public classes
Nonpublic classes
From Classes Come Modules
Chapter 15 Fancy Reference Types
Java’s Types
The Java Interface
Declaring 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 Java’s Juggling Act
Juggling Two or More Calls
Events and event handling
Follow the thread
Don’t miss this
Inside the actionPerformed method
Some Events Aren’t Button Clicks
The Inner Sanctum
Chapter 17 Using Java Database Connectivity
Creating a Database and a Table
Seeing what happens when you run the code
Using SQL commands
Connecting and disconnecting
Putting Data in the Table
Retrieving Data
Destroying Data
One Step Beyond
Part 5 The Part of Tens
Chapter 18 Ten Packs of Java Websites
This Book’s Website
For Business Issues Related to This Book
Download the Java Development Kit
Your Grandparents’ Java Download Site
The Horse’s Mouth
Join Java User Groups
Find the Latest News about Java
Find News, Reviews, and Sample Code
Got a Technical Question about Anything?
Become Involved in the Future of Java
Chapter 19 Ten Bits of Advice for New Software Developers
How Long Does It Take to Learn Java?
Which of Your Books Should I Read?
Are Books Other than Yours Good for Learning Java and Android Development?
Which Computer Programming Language(s) Should I Learn?
Which Skills Other than Computer Coding Should I Learn?
How Should I Continue My Learning as a Software Developer?
How Else Should I Continue My Learning as a Developer?
How Can I Land a Job Developing Software?
I Still Don’t Know What to Do with My Life
If I Have Other Questions, How Can I Contact You?
Index
EULA