Free Shipping on orders over $25

Book Details

  • Paperback
  • Bookstore's Wholesale Price: $98.66
  • July 2000
  • ISBN: 978-0-393-97437-9
  • 816 pages
  • Territory Rights: Worldwide

More Textbooks

  1. Computer Science

Java Programming

From the Beginning

Paperback

See all options and formats starting at
$123.32

K. N. King (Author, Georgia State University)

 

Aimed at the traditional CS1 course, Java Programming emphasizes object-oriented design, problem-solving, and good programming style, without overwhelming students with extraneous information.

Assuming no prior programming experience, the book provides coverage of basic concepts in computer science as a springboard for more advanced discussion.

More...

    Preface

    1 GETTING STARTED

    1.1 What Do Computers Do?

    • Hardware
    • Software

    1.2 Ways of Interacting With Computers?

    • Graphical User Interfaces
    • Text-Based Interfaces

    1.3 What Is Programming?

    • A Real-World Algorithm
    • Computer Algorithms
    • Expressing Algorithms

    1.4 Storing Data

    • Variables

    1.5 Programming Languages

    • Writing and Executing a Program

    1.6 Why Java?

    1.7 The Programming Process

    1.8 What You Need to Know

    2 WRITING JAVA PROGRAMS

    2.1 A Simple Java Program

    • Program: Printing a Message
    • Java Programs in General

    2.2 Executing a Java Program

    • Entering a Java Program
    • Compiling a Java Program
    • Running a Java Program
    • Using Multiple Windows

    2.3 Program Layout

    • Comments
    • Tokens
    • Indentation and Brace Placement

    2.4 Using Variables

    • Declaring Variables
    • Initializing Variables
    • Changing the Value of a Variable
    • Program: Printing a Lottery Number

    2.5 Type

    • Literals

    2.6 Identifiers

    • Keywords

    2.7 Performing Calculations

    • Operators
    • Precedence and Associativity
    • Assignment Operators
    • Program: Converting Fahrenheit to Celsius

    2.8 Constants

    2.9 Methods

    • Methods in the Math Class
    • Using the Result of a Method Call

    2.10 Input and Output

    • Displaying Output on the Screen
    • Escape Sequences
    • Printing Multiple Items
    • Obtaining Input from the User
    • Packages
    • Program: Converting from Fahrenheit to Celsius (Revisited)

    2.11 Case Study: Computing a Course Average

    • Improving the Program

    2.12 Debugging

    • Types of Errors
    • Fixing Compile-Time Errors
    • Fixing Run-Time Errors
    • Fixing Behavior Errors
    • Using a Debugger
    • Debugging Without a Debugger
    • Choosing Test Data

    3 CLASSES AND OBJECTS

    3.1 Objects as Models

    3.2 Representing Objects Within a Program

    • Instance Variables
    • Instance Methods

    3.3 Classes

    • Declaring a Class
    • Declaring Instance Variables
    • Declaring Instance Methods
    • Method Overloading
    • Declaring Constructors
    • Example: An Account Class

    3.4 Creating Objects

    3.5 Calling Instance Methods

    • How Instance Methods Work

    3.6 Writing Programs with Multiple Classes

    3.7 How Objects Are Stored

    • The null Keyword
    • Object Assignment
    • Garbage

    3.8 Developing a Fraction Class

    • Getters and Setters
    • Writing the add Method
    • Adding a toString Method

    3.9 Java's String Class

    • Creating Strings
    • Common String Methods
    • Chaining Calls of Instance Methods
    • Using + to Concatenate Strings
    • Program: Decoding a Vehicle Identification Number

    3.10 Case Study: Checking an ISBN Number

    4 BASIC CONTROL STRUCTURES

    4.1 Performing Comparisons

    • Relational Operators
    • Equality Operators
    • Testing Floating-Point Numbers for Equality
    • Testing Objects for Equality
    • Comparing Strings

    4.2 Logical Operators

    • Performing the And Operation
    • Performing the Or Operation
    • Performing the Not Operation
    • Precedence and Associativity of And, Or, and Not
    • Simplifying boolean Expressions

    4.3 Simple if Statements

    • Indentation
    • The Empty Statement
    • Blocks

    4.4 if Statements with else Clauses

    • Cascaded if Statements
    • Simplifying Cascaded if Statements
    • Program: Flipping a Coin
    • The "Dangling else" Problem

    4.5 The boolean Type

    • Program: Flipping a Coin (Revisited)

    4.6 Loops

    • Types of Loops
    • The while Statement
    • Blocks as Loop Bodies
    • Declaring Variables in Blocks
    • Example: Improving the Fraction Constructor

    4.7 Counting Loops

    • Increment and Decrement Operators
    • Using the Increment and Decrement Operators in Loops
    • Program: Counting Coin Flips

    4.8 Exiting from a Loop: The break Statement

    4.9 Case Study: Decoding Social Security Numbers

    4.10 Debugging

    5 ARRAYS

    5.1 Creating and Using Arrays

    • Creating Arrays
    • Array Subscripting
    • Processing the Elements in an Array
    • Program: Computing an Average Score

    5.2 The for Statement

    • for Statements Versus while Statements
    • for Statement Idioms
    • Omitting Expressions in a for Statement
    • Declaring Control Variables
    • Commas in for Statements
    • Program: Computing an Average Score (Revisited)

    5.3 Accessing Array Elements Sequentially

    • Searching for a Particular Element
    • Continuing Occurrences
    • Finding the Largest and Smallest Elements

    5.4 Accessing Array Elements Randomly

    • Program: Finding Repeated Digits in a Number

    5.5 Using Arrays as Vectors

    • Scaling a Vector
    • Adding Vectors
    • Computing the Inner Product of Two Vectors

    5.6 Using Arrays as Databases

    • Parallel Arrays
    • Arrays of Objects
    • Creating a Database
    • Adding a Record from a Database
    • Removing a Record from a Database
    • Searching a Database
    • Modifying a Record in Database

    5.7 Arrays as Objects

    • Resizing an Array

    5.8 Case Study: A Phone Directory

    6 GRAPHICS

    6.1 Creating a Drawing

    • Using Graphics Methods
    • The DrawableFrame class
    • Program: Drawing a Line
    • Drawing Rectangles
    • Drawing Ovals
    • Drawing Arcs
    • Drawing Polygons
    • Drawing Polylines

    6.2 Drawing in Color

    6.3 Displaying Text

    • The Font Class
    • Program: Displaying Text in Different Colors

    6.4 Combining Text with Graphics

    • Program: Displaying a Stop Sign
    • The FontMetrics Class
    • Program: Obtaining Font Information

    6.5 Case Study: A Message Window

    6.6 Debugging

    7 CLASS VARIABLES AND METHODS

    7.1 Class Methods Versus Instance Methods

    • Class Methods
    • Example: The Math Class
    • Example: The System Class
    • Example: The String Class
    • Summary

    7.2 Writing Class Methods

    • Example: A Termination Method
    • Local Variables

    7.3 The return Statement

    • Example: A Dollar-Formatting Method
    • Conditional Expressions

    7.4 Parameters

    • How Arguments Are Passed
    • Array Parameters
    • Program Arguments
    • Program: Printing Command-Line Arguments

    7.5 Class Variables

    • Declaring Class Variables
    • Uses for Class Variables
    • Using Class Variables as Global Variables
    • Class Variables in the System Class
    • Using Class Variables as Constants
    • Using Class Variables to Store Data for Class Methods
    • Summary

    7.6 Adding Class Variables and Methods to a Class

    • Example: Modifying the DisplayText Program

    7.7 Writing Helper Methods

    • Improving Clarity
    • Reducing Redundancy
    • The Revised CourseAverage Program
    • Reusing Helper Methods

    7.8 Designing Methods

    • Cohesion
    • Stepwise Refinement
    • Choosing Method Names
    • Parameters Versus Class Variables
    • Return Type

    8 MORE CONTROL STRUCTURES

    8.1 Exceptions

    • Handling Exceptions
    • Variables and try Blocks
    • Accessing Information About an Exception
    • Terminating the Program After an Exception
    • Converting Strings to Integers
    • Multiple catch Blocks
    • Checked Exceptions Versus Unchecked Exceptions
    • Using Exceptions Properly

    8.2 The switch Statement

    • Combining Case Labels
    • The default Case
    • The General Form of the switch Statement
    • Layout of the switch Statement
    • Advantages of the switch Statement
    • Limitations of the switch Statement
    • The Role of the break Statement
    • Program: Determining the Number of Days in a Month

    8.3 The do Statement

    8.4 The continue Statement

    8.5 Nested Loops

    • Labeled break Statements
    • Labeled continue Statements
    • Program: Computing Interest

    8.6 Case Study: Printing a One-Month Calendar

    8.7 Debugging

    9 PRIMITIVE TYPES

    9.1 Types

    • Literals

    9.2 Integer Types

    • Integer Literals
    • Converting Strings to Integers

    9.3 Floating-Point Types

    • Floating-Point Literals
    • Special Values
    • The Math Class

    9.4 The char Type

    • The ASCII Character Set
    • The Unicode Character Set
    • Escape Sequences
    • Operations on Characters
    • Characters Versus Strings
    • The Character Class

    9.5 Type Conversion

    • Implicit Conversions
    • Numeric Promotion
    • Conversion During Assignment
    • Argument Conversion
    • Casting
    • Program: Encrypting a Message Using Rot13 Technique

    9.6 Case Study: Drawing Random Circles

    10 WRITING CLASSES

    10.1 Designing Classes

    • Object-Oriented Analysis
    • Design Issues
    • Naming Classes
    • Instantiable or Not?
    • Mutable or Immutable?

    10.2 Choosing Instance Variables

    • How Many Instance Variables?
    • Public Instance Variables
    • Information Hiding
    • The "Hidden Variable" Problem

    10.3 Designing Instance Methods

    • Categories of Methods
    • Manager Methods
    • Implementor Methods
    • Access Methods
    • Helper Methods
    • Using Class Methods as Helpers
    • Method Overloading

    10.4 The this Keyword

    • Using this to Access Hidden Variables
    • Using this to Call Instance Methods
    • Using this as an Argument
    • Using this as a Return Value

    10.5 Writing Constructors

    • Using this in Constructors
    • "No-Arg" Constructors
    • Constructors Versus Instance Variable Initialization

    10.6 Example: The Fraction Class

    10.7 Adding Class Variables and Methods

    • Class Variables in Instantiable Classes
    • Class Methods in Instantiable Classes
    • Restrictions on Class Methods

    10.8 Reusing Code

    • Reusing Class Methods
    • Reusing Classes
    • Writing Packages

    10.9 Case Study: Playing Blackjack

    10.10 Debugging

    11 SUBCLASSES

    11.1 Inheritance

    • Writing a Subclass
    • Writing Subclass Constructors
    • Illustrating Inheritance
    • When Not to Use Inheritance

    11.2 The protected Access Modifier

    • Use of protected
    • protected Versus private

    11.3 Overriding

    11.4 Polymorphism

    • Casting Object References
    • Advantages of Polymorphism

    11.5 The Object Class

    • Object Methods
    • The equals Method
    • The toString Method

    11.6 Abstract Classes

    • Example: A Shape Class

    11.7 Final classes and Methods

    11.8 Inheritance in the Abstract Window Toolkit

    • Components
    • Relationships Among Component Classes

    11.9 Case Study: "Nervous" Shapes

    12 THE ABSTRACT WINDOW TOOLKIT

    12.1 Overview

    • Swing
    • Creating a Graphical User Interface

    12.2 Frames

    • Frame Methods
    • Creating a Frame
    • Setting the Frame Location
    • Adding Components to the Frame

    12.3 Event Listeners

    • Events
    • Interfaces
    • Creating Event Listeners
    • Adapter Classes

    12.4 Inner Classes

    12.5 Attaching Listeners to Multiple Components

    • Example: A Single Listener
    • Example: Separate Listeners

    12.6 Layout

    • Layout Manager Classes
    • The FlowLayout Class
    • The GridLayout Class
    • The BorderLayout Class
    • Preferred Sizes
    • Panels

    12.7 Creating and Using Components

    • Checkboxes
    • Checkbox Groups
    • Choice Menus
    • Labels
    • Lists
    • Scrollbars
    • Text Areas
    • Text Fields

    12.8 Examples

    • Using Labels and Text Fields: Temperature Conversion
    • Using Lists and Text Areas: Showing Definitions
    • Using Labels and Scrollbars: Picking Colors

    13 DATA STRUCTURES

    13.1 Multidimensional Arrays

    • Creating and Initializing a Multidimensional Array
    • Subscripting a Multidimensional Array
    • Processing the Elements in a Multidimensional Array
    • How Multidimensional Arrays Are Stored
    • Using Two-Dimensional Arrays as Matrices
    • Using Two-Dimensional Arrays to Store Images
    • Ragged Arrays
    • Using Multidimensional Arrays as Parameters and Results
    • Program: Finding the Distance Between Two Cities

    13.2 The Vector Class

    • Arrays Versus Vectors
    • Program: Reversing a Series of Lines

    13.3 Wrapper Classes

    • Using Wrapper classes to Create Objects

    13.4 Sorting

    • Inserting into a Sorted Array
    • Insertion Sort
    • Program: Sorting a Series of Lines

    13.5 Searching

    • Program: determining Air Mileage

    13.6 Sets

    • Bit Sets
    • Program: Finding Primes Using the Sieve of Eratosthenes

    13.7 The StringBuffer Class

    • Program: Sorting the Characters in a String

    13.8 Case Study: Finding Anagrams

    14 FILES

    14.1 Files and Streams

    • How Files Are Stored
    • Text Files Versus Binary Files
    • Streams
    • Stream Layering
    • Working with Files
    • Obtaining File Names
    • Buffering and Flushing
    • File Pointers

    14.2 The File Class

    • File Properties
    • Program: Determining the Properties of a File
    • Program: Listing the Files in a Directory
    • File Operations
    • Program: Renaming the Files in a Directory

    14.3 Reading and Writing Bytes

    • Writing Bytes
    • Reading Bytes
    • Program: Copying a File

    14.4 Advanced Exception-Handling

    • The Hierarchy of Exception Classes
    • Using Multiple catch Blocks
    • finally Blocks
    • The throws Clause
    • Program: Copy a File (Revisited)

    14.5 Reading and Writing Data Types

    • Writing Data Types
    • Writing Strings
    • Reading Data Types

    14.6 Reading and Writing Characters

    • Writing to a Text File
    • Reading from a Text File
    • Program: Converting Text to HTML

    14.7 Reading and Writing Objects

    • The Serializable Interface
    • Writing Objects
    • Reading Objects
    • Reading and Writing Entire Data Structures

    14.8 Case Study: A Phone Directory (Revisited)

    Appendix A Setting Up Java

    Appendix B Java Language Summary

    Appendix C Java API Summary

    Appendix D Applets

    Appendix E The jpb Package

    Bibliography

    Index