O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Java For Dummies, 7th Edition

Book Description

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!

Table of Contents

    1. Cover
    2. Introduction
      1. How to Use This Book
      2. Conventions Used in This Book
      3. What You Don’t Have to Read
      4. Foolish Assumptions
      5. How This Book Is Organized
      6. Icons Used in This Book
      7. Beyond the Book
      8. Where to Go from Here
    3. Part 1: Getting Started with Java
      1. Chapter 1: All about Java
        1. What You Can Do with Java
        2. Why You Should Use Java
        3. Getting Perspective: Where Java Fits In
        4. Object-Oriented Programming (OOP)
        5. What’s Next?
      2. Chapter 2: All about Software
        1. Quick-Start Instructions
        2. What You Install on Your Computer
      3. Chapter 3: Using the Basic Building Blocks
        1. Speaking the Java Language
        2. Checking Out Java Code for the First Time
        3. Understanding a Simple Java Program
        4. And Now, a Few Comments
    4. Part 2: Writing Your Own Java Programs
      1. Chapter 4: Making the Most of Variables and Their Values
        1. Varying a Variable
        2. Experimenting with JShell
        3. What Happened to All the Cool Visual Effects?
        4. The Atoms: Java’s Primitive Types
        5. The Molecules and Compounds: Reference Types
        6. An Import Declaration
        7. Creating New Values by Applying Operators
      2. Chapter 5: Controlling Program Flow with Decision-Making Statements
        1. Making Decisions (Java if Statements)
        2. Using Blocks in JShell
        3. Forming Conditions with Comparisons and Logical Operators
        4. Building a Nest
        5. Choosing among Many Alternatives (Java switch Statements)
      3. Chapter 6: Controlling Program Flow with Loops
        1. Repeating Instructions Over and Over Again (Java while Statements)
        2. Repeating a Certain Number of Times (Java for Statements)
        3. Repeating until You Get What You Want (Java do Statements)
    5. Part 3: Working with the Big Picture: Object-Oriented Programming
      1. Chapter 7: Thinking in Terms of Classes and Objects
        1. Defining a Class (What It Means to Be an Account)
        2. Defining a Method within a Class (Displaying an Account)
        3. Sending Values to and from Methods (Calculating Interest)
        4. Making Numbers Look Good
        5. Hiding Details with Accessor Methods
        6. Barry’s Own GUI Class
      2. Chapter 8: Saving Time and Money: Reusing Existing Code
        1. Defining a Class (What It Means to Be an Employee)
        2. Working with Disk Files (a Brief Detour)
        3. Defining Subclasses (What It Means to Be a Full-Time or Part-Time Employee)
        4. Using Subclasses
        5. Overriding Existing Methods (Changing the Payments for Some Employees)
      3. Chapter 9: Constructing New Objects
        1. Defining Constructors (What It Means to Be a Temperature)
        2. More Subclasses (Doing Something about the Weather)
        3. A Constructor That Does More
    6. Part 4: Smart Java Techniques
      1. Chapter 10: Putting Variables and Methods Where They Belong
        1. Defining a Class (What It Means to Be a Baseball Player)
        2. Making Static (Finding the Team Average)
        3. Experiments with Variables
        4. Passing Parameters
      2. Chapter 11: Using Arrays to Juggle Values
        1. Getting Your Ducks All in a Row
        2. Arrays of Objects
        3. Command Line Arguments
      3. Chapter 12: Using Collections and Streams (When Arrays Aren’t Good Enough)
        1. Understanding the Limitations of Arrays
        2. Collection Classes to the Rescue
        3. Functional Programming
      4. Chapter 13: Looking Good When Things Take Unexpected Turns
        1. Handling Exceptions
        2. Handle an Exception or Pass the Buck
        3. Finishing the Job with a finally Clause
        4. A try Statement with Resources
      5. Chapter 14: Sharing Names among the Parts of a Java Program
        1. Access Modifiers
        2. Classes, Access, and Multipart Programs
        3. Sneaking Away from the Original Code
        4. Protected Access
        5. Access Modifiers for Java Classes
      6. Chapter 15: Fancy Reference Types
        1. Java’s Types
        2. The Java Interface
        3. Abstract Classes
        4. Relax! You’re Not Seeing Double!
      7. Chapter 16: Responding to Keystrokes and Mouse Clicks
        1. Go On … Click That Button
        2. Responding to Things Other Than Button Clicks
        3. Creating Inner Classes
      8. Chapter 17: Using Java Database Connectivity
        1. Creating a Database and a Table
        2. Putting Data in the Table
        3. Retrieving Data
        4. Destroying Data
    7. Part 5: The Part of Tens
      1. Chapter 18: Ten Ways to Avoid Mistakes
        1. Putting Capital Letters Where They Belong
        2. Breaking Out of a switch Statement
        3. Comparing Values with a Double Equal Sign
        4. Adding Components to a GUI
        5. Adding Listeners to Handle Events
        6. Defining the Required Constructors
        7. Fixing Non-Static References
        8. Staying within Bounds in an Array
        9. Anticipating Null Pointers
        10. Helping Java Find Its Files
      2. Chapter 19: Ten Websites for Java
        1. This Book’s Website
        2. The Horse’s Mouth
        3. Finding News, Reviews, and Sample Code
        4. Got a Technical Question?
    8. About the Author
    9. Connect with Dummies
    10. End User License Agreement