Sams Teach Yourself Java in 24 Hours, Eighth Edition

Book description

Computer programming with Java is easier than it looks. In just 24 lessons of one hour or less, you can learn to write computer programs in Java.

Using a straightforward, step-by-step approach, popular author Rogers Cadenhead helps you master the skills and technology you need to create desktop and web programs, web services, an Android app, and even Minecraft mods in Java.

Each lesson builds on what you’ve already learned, giving you a rock-solid foundation for real-world success.

Full-color figures and clear step-by-step instructions visually show you how to program with Java.

Quizzes and Exercises at the end of each chapter help you test your knowledge.

Notes, Tips, and Cautions provide related information, advice, and warnings.

Learn how to…

  • Set up your Java programming environment
  • Write your first working program in just minutes
  • Control program decisions and behavior
  • Store and work with information
  • Build straightforward user interfaces
  • Create interactive web programs
  • Use threading to build more responsive programs
  • Read and write files and XML data
  • Master best practices for object-oriented programming
  • Use Java 9’s new HTTP client
  • Use Java to create an Android app
  • Expand your skills with closures
  • Create Minecraft mods with Java

Contents at a Glance

Part I Getting Started

1 Becoming a Programmer

2 Writing Your First Program

3 Vacationing in Java

4 Understanding How Java Programs Work

Part II Learning the Basics of Programming

5 Storing and Changing Information in a Program

6 Using Strings to Communicate

7 Using Conditional Tests to Make Decisions

8 Repeating an Action with Loops

Part III Working with Information in New Ways

9 Storing Information with Arrays

10 Creating Your First Object

11 Describing What Your Object is Like

12 Making the Most of Existing Objects

Part IV Moving into Advanced Topics

13 Storing Objects in Data Structures

14 Handling Errors in a Program

15 Creating a Threaded Program

16 Using Inner Classes and Closures

Part V Programming a Graphical User Interface

17 Building a Simple User Interface in Swing

18 Laying Out a User Interface

19 Responding to User Input

Part VI Writing Internet Applications

20 Reading and Writing Files

21 Using Java 9's New HTTP Client

22 Creating Java2D Graphics

23 Creating Minecraft Mods with Java

24 Writing Android Apps

Appendixes

A Using the NetBeans Integrated Development Environment

B Where to Go from Here Java Resources

C This Book's Web Site

D Fixing a Problem with the Android Studio Emulator

Table of contents

  1. Cover Page
  2. Title Page
  3. Copyright Page
  4. Dedication
  5. Table of Contents
  6. Introduction
  7. PART I: Getting Started
    1. HOUR 1: Becoming a Programmer
      1. Choosing a Language
      2. Telling the Computer What to Do
      3. How Programs Work
      4. When Programs Don–t Work
      5. Choosing a Java Programming Tool
      6. Installing a Java Development Tool
    2. HOUR 2: Writing Your First Program
      1. What You Need to Write Programs
      2. Creating the Saluton Program
      3. Beginning the Program
        1. The class Statement
        2. What the main Statement Does
        3. Those Squiggly Bracket Marks
      4. Storing Information in a Variable
        1. Displaying the Contents of a Variable
      5. Saving the Finished Product
      6. Compiling the Program into a Class File
      7. Fixing Errors
      8. Running a Java Program
    3. HOUR 3: Vacationing in Java
      1. First Stop: Oracle
        1. A Brief History of Java
      2. Going to School with Java
      3. Lunch at Food Network
      4. Watching the Skies at NASA
      5. Getting Down to Business
      6. Stopping by SourceForge for Directions
    4. HOUR 4: Understanding How Java Programs Work
      1. Creating an Application
      2. Sending Arguments to Applications
      3. The Java Class Library
      4. Trying Java Statements in JShell
  8. PART II: Learning the Basics of Programming
    1. HOUR 5: Storing and Changing Information in a Program
      1. Statements and Expressions
      2. Assigning Variable Types
        1. Integers and Floating-Point Numbers
        2. Characters and Strings
        3. Other Numeric Variable Types
        4. The boolean Variable Type
      3. Naming Your Variables
      4. Storing Information in a Variable
      5. All About Operators
        1. Incrementing and Decrementing a Variable
        2. Operator Precedence
      6. Using Expressions
    2. HOUR 6: Using Strings to Communicate
      1. Storing Text in Strings
      2. Displaying Strings in Programs
      3. Using Special Characters in Strings
      4. Pasting Strings Together
      5. Using Other Variables with Strings
      6. Advanced String Handling
        1. Comparing Two Strings
        2. Determining the Length of a String
        3. Copying a String with a New Case
        4. Looking for a String
      7. Presenting Credits
    3. HOUR 7: Using Conditional Tests to Make Decisions
      1. if Statements
        1. Less-Than and Greater-Than Comparisons
        2. Equal and Not Equal Comparisons
        3. Organizing a Program with Block Statements
      2. if-else Statements
      3. switch Statements
      4. The Ternary Operator
      5. Watching the Clock
    4. HOUR 8: Repeating an Action with Loops
      1. for Loops
      2. while Loops
      3. do-while Loops
      4. Exiting a Loop
      5. Naming a Loop
        1. Complex for Loops
      6. Testing Your Computer Speed
  9. PART III: Working with Information in New Ways
    1. HOUR 9: Storing Information with Arrays
      1. Creating Arrays
      2. Using Arrays
      3. Multidimensional Arrays
      4. Sorting an Array
      5. Counting Characters in Strings
    2. HOUR 10: Creating Your First Object
      1. How Object-Oriented Programming Works
      2. Objects in Action
      3. What Objects Are
      4. Understanding Inheritance
      5. Building an Inheritance Hierarchy
      6. Converting Objects and Simple Variables
        1. Casting Simple Variables
        2. Casting Objects
        3. Converting Simple Variables to Objects and Back
      7. Creating an Object
    3. HOUR 11: Describing What Your Object Is Like
      1. Creating Variables
      2. Creating Class Variables
      3. Creating Behavior with Methods
        1. Declaring a Method
        2. Similar Methods with Different Arguments
        3. Constructors
        4. Class Methods
        5. Variable Scope within Methods
      4. Putting One Class Inside Another
      5. Using the this Keyword
      6. Using Class Methods and Variables
    4. HOUR 12: Making the Most of Existing Objects
      1. The Power of Inheritance
        1. Inheriting Behavior and Attributes
        2. Overriding Methods
      2. Establishing Inheritance
        1. Using this and super in a Subclass
      3. Working with Existing Objects
      4. Storing Objects of the Same Class in Array Lists
        1. Looping Through an Array List
      5. Creating a Subclass
  10. PART IV: Moving into Advanced Topics
    1. HOUR 13: Storing Objects in Data Structures
      1. Array Lists
      2. Hash Maps
    2. HOUR 14: Handling Errors in a Program
      1. Exceptions
        1. Catching Exceptions in a try-catch Block
        2. Catching Several Different Exceptions
        3. Handling Something After an Exception
        4. Throwing Exceptions
        5. Ignoring Exceptions
        6. Exceptions That Don–t Need catch
      2. Throwing and Catching Exceptions
    3. HOUR 15: Creating a Threaded Program
      1. Threads
        1. Slowing Down a Program
        2. Creating a Thread
      2. Working with Threads
        1. The class Declaration
        2. Setting Up Variables
      3. The Constructor
      4. Catching Errors as You Set Up URLs
      5. Starting the Thread
        1. Running the Thread
      6. Handling Mouse Clicks
      7. Displaying Revolving Links
        1. Stopping a Thread
    4. HOUR 16: Using Inner Classes and Closures
      1. Inner Classes
        1. Anonymous Inner Classes
      2. Closures
  11. PART V: Programming a Graphical User Interface
    1. HOUR 17: Building a Simple User Interface
      1. Swing and the Abstract Windowing Toolkit
      2. Using Components
        1. Windows and Frames
      3. Buttons
      4. Labels and Text Fields
      5. Check Boxes
      6. Combo Boxes
      7. Text Areas
      8. Panels
      9. Creating Your Own Component
    2. HOUR 18: Laying Out a User Interface
      1. Using Layout Managers
        1. The GridLayout Manager
        2. The BorderLayout Manager
        3. The BoxLayout Manager
        4. Separating Components with Insets
      2. Laying Out an Application
    3. HOUR 19: Responding to User Input
      1. Getting Your Programs to Listen
      2. Setting Up Components to Be Heard
      3. Handling User Events
        1. Check Box and Combo Box Events
        2. Keyboard Events
        3. Enabling and Disabling Components
      4. Completing a Graphical Application
  12. PART VI: Writing Internet Applications
    1. HOUR 20: Reading and Writing Files
      1. Streams
        1. Files
        2. Reading Data from a Stream
        3. Buffered Input Streams
      2. Writing Data to a Stream
      3. Reading and Writing Configuration Properties
    2. HOUR 21: Using Java 9–s New HTTP Client
      1. Java Modules
      2. Making an HTTP Request
      3. Saving a File from the Web
      4. Posting Data on the Web
    3. HOUR 22: Creating Java2D Graphics
      1. Using the Font Class
      2. Using the Color Class
      3. Creating Custom Colors
        1. Drawing Lines and Shapes
        2. Drawing Lines
        3. Drawing Rectangles
        4. Drawing Ellipses and Circles
        5. Drawing Arcs
      4. Baking a Pie Graph
    4. HOUR 23: Creating Minecraft Mods with Java
      1. Setting Up a Minecraft Server
        1. Fixing Problems Running the Server
      2. Connecting to the Server
        1. Fixing a Server Connection Problem
      3. Creating Your First Mod
      4. Teaching Zombies to Ride Horses
      5. Finding All Mobs (and Killing Them)
      6. Writing a Mod that Can Build Things
    5. HOUR 24: Writing Android Apps
      1. Introduction to Android
      2. Creating an Android App
        1. Exploring a New Android Project
        2. Creating an App
        3. Setting Up an Android Emulator
      3. Running the App
      4. Designing a Real App
        1. Organizing Resources
        2. Configuring the App–s Manifest File
        3. Designing a User Interface
        4. Writing Java Code
  13. APPENDIXES
    1. APPENDIX A: Using the NetBeans Integrated Development Environment
      1. Installing NetBeans
      2. Creating a New Project
      3. Creating a New Java Class
      4. Running the Application
      5. Fixing Errors
    2. APPENDIX B: Where to Go from Here: Java Resources
      1. Other Books to Consider
      2. Oracle–s Official Java Site
        1. Java Class Documentation
      3. Other Java Websites
        1. This Book–s Official Site
        2. Workbench
        3. Slashdot
        4. Other Java Weblogs
        5. InformIT
        6. Stack Overflow
        7. JavaWorld Magazine
        8. Developer.com–s Java Directory
      4. Java Meetings
      5. Job Opportunities
    3. APPENDIX C: This Book–s Website
    4. APPENDIX D: Fixing a Problem with the Android Studio Emulator
      1. Problems Running an App
      2. Install HAXM in Android Studio
      3. Install HAXM on Your Computer
      4. Checking BIOS Settings
    5. APPENDIX E: Fixing Package Not Visible Errors in NetBeans
      1. Adding Module Info
    6. Index

Product information

  • Title: Sams Teach Yourself Java in 24 Hours, Eighth Edition
  • Author(s): Rogers Cadenhead
  • Release date: September 2017
  • Publisher(s): Sams
  • ISBN: 9780134663647