Java: An Introduction to Problem Solving and Programming, 8th Edition

Book description

For courses in introductory Computer Science courses using Java, and other introductory programming courses in Computer Science, Computer Engineering, CIS, MIS, IT, and Business.

A Concise, Accessible Introduction to Java Programming

Ideal for a wide range of introductory computer science applications, Java: An Introduction to Problem Solving and Programming, 8th Edition introduces readers to object-oriented programming and important concepts such as design, testing and debugging, programming style, interfaces and inheritance, and exception handling. A concise, accessible introduction to Java, the text covers key Java language features in a manner that resonates with introductory programmers. Objects are covered early and thoroughly in the text. The author’s tried-and-true pedagogy incorporates numerous case studies, programming examples, and programming tips, while flexibility charts and optional graphics sections allow readers to review chapters and sections based on their needs. This 8th Edition incorporates new examples, updated material, and revisions.

Also available with MyLab Programming

MyLab™ Programming is an online learning system designed to engage students and improve results. MyLab Programming consists of programming exercises correlated to the concepts and objectives in this book. Through practice exercises and immediate, personalized feedback, MyLab Programming improves the programming competence of beginning students who often struggle with the basic concepts of programming languages.

Note: You are purchasing a standalone product; MyLab™ Programming does not come packaged with this content. Students, if interested in purchasing this title with MyLab Programming , ask your instructor for the correct package ISBN and Course ID. Instructors, contact your Pearson representative for more information.

If you would like to purchase both the physical text and MyLab Programming , search for:

0134710754 / 9780134710754 Java: An Introduction to Problem Solving and Programming Plus MyLab Programming with Pearson eText -- Access Card Package, 8/e

Package consists of:

  • 0134462033 / 9780134462035 Java: An Introduction to Problem Solving and Programming

  • 0134459865 / 9780134459868 MyLab Programming with Pearson eText--Access Code Card--for Java: An Introduction to Problem Solving and Programming

Table of contents

  1. Java™ An Introduction to Problem Solving & Programming
  2. Java™ An Introduction to Problem Solving & Programming
  3. Preface for Instructors
    1. Changes in This Edition
    2. Latest Java Coverage
    3. Flexibility
    4. Early Graphics
    5. Coverage of Problem-Solving and Programming Techniques
    6. Early Introduction to Classes
    7. Generic Programming
    8. Language Details and Sample Code
    9. Self-Test Questions
    10. Exercises and Programming Projects
    11. Support Material
    12. Online Practice and Assessment with MyProgrammingLab
    13. VideoNotes
    14. Contact Us
  4. Preface for Students
    1. If You Have Programmed Before
    2. Obtaining a Copy of Java
    3. Support Materials for Students
    4. Learning Aids
    5. Online Practice with MyProgrammingLab
    6. VideoNotes
    7. This Text Is Also a Reference Book
  5. Dependency Chart
  6. Features of This Text
  7. Brief Contents
  8. Contents
  9. 1 Introduction to Computers and Java
    1. Introduction
    2. Objectives
    3. Prerequisites
    4. 1.1 Computer Basics
      1. Hardware and Memory
      2. Programs
      3. Programming Languages, Compilers, and Interpreters
      4. Java Bytecode
      5. Class Loader
      6. Self-Test Questions
    5. 1.2 A Sip of Java
      1. History of the Java Language
      2. Applications and Applets
      3. A First Java Application Program
        1. Examples:
      4. Self-Test Questions
      5. Writing, Compiling, and Running a Java Program
      6. Self-Test Questions
    6. 1.3 Programming Basics
      1. Object-Oriented Programming
      2. Algorithms
      3. Self-Test Questions
      4. Testing and Debugging
      5. Self-Test Questions
      6. Software Reuse
    7. 1.4 Graphics Supplement
      1. A Sample JavaFX Application
      2. Size and Position of Figures
      3. Drawing Ovals and Circles
        1. Syntax
      4. Drawing Arcs
        1. Syntax
      5. Self-Test Questions
    8. Chapter Summary
      1. Exercises
    9. Practice Programs
    10. Programming Projects
  10. 2 Basic Computation
    1. Objectives
    2. Prerequisites
    3. 2.1 Variables and Expressions
      1. Variables
        1. Syntax
        2. Examples
      2. Data Types
      3. Java Identifiers
      4. Assignment Statements
        1. Syntax
        2. Example
        3. Syntax
        4. Examples
      5. Simple Input
      6. Simple Screen Output
      7. Constants
      8. Named Constants
        1. Syntax
        2. Examples
      9. Assignment Compatibilities
      10. Type Casting
        1. Syntax
        2. Examples
      11. Self-Test Questions
      12. Arithmetic Operators
      13. Parentheses and Precedence Rules
      14. Specialized Assignment Operators
      15. Self-Test Questions
      16. Self-Test Question
      17. Increment and Decrement Operators
      18. More About the Increment and Decrement Operators
      19. Self-Test Question
    4. 2.2 The Class String
      1. String Constants and Variables
      2. Concatenation of Strings
        1. Example
      3. String Methods
      4. String Processing
      5. Escape Characters
      6. The Unicode Character Set
      7. Self-Test Questions
    5. 2.3 Keyboard and Screen I/O
      1. Screen Output
        1. Syntax
        2. Examples
      2. Keyboard Input
        1. Syntax
        2. Examples
      3. Other Input Delimiters (Optional)
      4. Formatted Output with printf (Optional)
      5. Self-Test Questions
    6. 2.4 Documentation and Style
      1. Meaningful Variable Names
      2. Comments
      3. Indentation
      4. Using Named Constants
      5. Self-Test Questions
    7. 2.5 Graphics Supplement
      1. Style Rules Applied to a JavaFx Application
      2. Introducing the Class JOptionPane
        1. Syntax For Input
        2. Example
        3. Syntax For Output
        4. Example
      3. Self-Test Questions
      4. Reading Input as Other Numeric Types
    8. Chapter Summary
      1. Exercises
    9. Practice Programs
    10. Programming Projects
  11. 3 Flow of Control: Branching
    1. Objectives
    2. Prerequisites
    3. 3.1 The if-else Statement
      1. The Basic if-else Statement
        1. Syntax (Basic Form)
        2. Example
        3. Syntax (No else Part)
        4. Example
        5. Compound Statement Alternatives
      2. Boolean Expressions
        1. Syntax
        2. Example
        3. Syntax
        4. Example
        5. Syntax
        6. Example
      3. Comparing Strings
        1. Syntax
        2. Example
      4. Self-Test Questions
      5. Nested if-else Statements
      6. Multibranch if-else Statements
        1. Syntax
        2. Example
      7. Self-Test Questions
      8. The Conditional Operator (Optional)
      9. The exit Method
    4. 3.2 The Type boolean
      1. Boolean Variables
      2. Precedence Rules
      3. Input and Output of Boolean Values
      4. Self-Test Questions
    5. 3.3 The switch Statement
      1. Syntax
      2. Example
      3. Self-Test Questions
      4. Enumerations
    6. 3.4 Graphics Supplement
      1. Specifying a Drawing Color
        1. Example
      2. Self-Test Questions
      3. A Dialog Box for a Yes-or-No Question
        1. Syntax
        2. Example
      4. Self-Test Question
    7. Chapter Summary
      1. Exercises
    8. Practice Programs
    9. Programming Projects
  12. 4 Flow of Control: Loops
    1. Objectives
    2. Prerequisites
    3. 4.1 Java Loop Statements
      1. The while Statement
        1. Syntax
        2. Example
        3. Example
      2. The do-while Statement
        1. Syntax
        2. Example
        3. Example
        4. Algorithm for roach population program (rough draft)
        5. Algorithm for roach population program
      3. Self-Test Questions
      4. The for Statement
        1. Syntax
        2. Example
      5. Declaring Variables Within a for Statement
      6. Using a Comma in a for Statement (Optional)
      7. Self-Test Questions
      8. The for-each Statement
    4. 4.2 Programming with Loops
      1. The Loop Body
      2. Initializing Statements
      3. Controlling the Number of Loop Iterations
        1. Algorithm for the store’s computer program
      4. The break Statement and continue Statement in Loops (Optional)
      5. Self-Test Questions
      6. Loop Bugs
      7. Tracing Variables
      8. Assertion Checks
        1. Syntax
        2. Example
      9. Self-Test Questions
    5. 4.3 Graphics Supplement
      1. Drawing Text
        1. Syntax
        2. Example
        3. Syntax
        4. Example
      2. Self-Test Questions
    6. Chapter Summary
      1. Exercises
    7. Practice Programs
    8. Programming Projects
  13. 5 Defining Classes and Methods
    1. Objectives
    2. Prerequisites
    3. 5.1 Class and Method Definitions
      1. Class Files and Separate Compilation
      2. Instance Variables
      3. Methods
      4. Defining void Methods
      5. Defining Methods That Return a Value
        1. Syntax
        2. Examples
      6. The Keyword this
      7. Self-Test Questions
      8. Local Variables
      9. Blocks
      10. Parameters of a Primitive Type
        1. Syntax
        2. Syntax
        3. Examples
      11. Self-Test Questions
    4. 5.2 Information Hiding and Encapsulation
      1. Information Hiding
      2. Precondition and Postcondition Comments
      3. The public and private Modifiers
      4. Accessor Methods and Mutator Methods
      5. Self-Test Questions
      6. Methods Calling Methods
      7. Self-Test Questions
      8. Encapsulation
      9. Automatic Documentation with javadoc
      10. UML Class Diagrams
      11. Self-Test Questions
    5. 5.3 Objects and References
      1. Variables of a Class Type
      2. Defining an equals Method for a Class
      3. Boolean-Valued Methods
      4. Self-Test Questions
      5. Parameters of a Class Type
      6. Self-Test Questions
    6. 5.4 Graphics Supplement
      1. The GraphicsContext Class
      2. Self-Test Questions
      3. Adding Labels to a JavaFX Application
    7. Chapter Summary
      1. Exercises
    8. Practice Programs
    9. Programming Projects
  14. 6 More About Objects and Methods
    1. Objectives
    2. Prerequisites
    3. 6.1 Constructors
      1. Defining Constructors
        1. Examples
      2. Calling Methods from Constructors
      3. Self-Test Questions
      4. Calling a Constructor from Other Constructors (Optional)
        1. Example
    4. 6.2 Static Variables and Static Methods
      1. Static Variables
      2. Static Methods
      3. Self-Test Questions
      4. Dividing the Task of a main Method into Subtasks
      5. Adding a main Method to a Class
      6. The Math Class
      7. Self-Test Questions
      8. Wrapper Classes
      9. Self-Test Questions
    5. 6.3 Writing Methods
      1. Decomposition
      2. Addressing Compiler Concerns
      3. Testing Methods
      4. Self-Test Questions
    6. 6.4 Overloading
      1. Overloading Basics
      2. Overloading and Automatic Type Conversion
      3. Overloading and the Return Type
      4. Self-Test Questions
      5. Self-Test Questions
    7. 6.5 Information Hiding Revisited
      1. Privacy Leaks
      2. Self-Test Question
    8. 6.6 Enumeration as a Class
      1. Self-Test Question
    9. 6.7 Packages
      1. Packages and Importing
        1. Syntax for a Class in a Package
        2. Examples
        3. Syntax
        4. Examples
      2. Package Names and Directories
        1. Examples
      3. Name Clashes
      4. Self-Test Questions
    10. 6.8 Graphics Supplement
      1. Adding Buttons
      2. Adding Icons
      3. Self-Test Question
    11. Chapter Summary
      1. Exercises
    12. Practice Programs
    13. Programming Projects
  15. 7 Arrays
    1. Objectives
    2. Prerequisites
    3. 7.1 Array Basics
      1. Creating and Accessing Arrays
      2. Array Details
        1. Syntax
        2. Examples
      3. The Instance Variable length
      4. More About Array Indices
      5. Initializing Arrays
      6. Self-Test Questions
    4. 7.2 Arrays in Classes and Methods
      1. Self-Test Questions
      2. Indexed Variables as Method Arguments
      3. Entire Arrays as Arguments to a Method
        1. Syntax
        2. Examples
      4. Arguments for the Method main
      5. Array Assignment and Equality
      6. Methods That Return Arrays
        1. Syntax
        2. Example
        3. Examples
      7. Self-Test Questions
    5. 7.3 Programming with Arrays and Classes
      1. Self-Test Questions
      2. Partially Filled Arrays
      3. Self-Test Questions
    6. 7.4 Sorting and Searching Arrays
      1. Selection Sort
        1. Algorithm for a selection sort of an array
      2. Other Sorting Algorithms
      3. Self-Test Questions
      4. Searching an Array
    7. 7.5 Multidimensional Arrays
      1. Multidimensional-Array Basics
        1. Syntax
        2. Examples
      2. Multidimensional-Array Parameters and Returned Values
        1. Syntax
        2. Examples
      3. Java’s Representation of Multidimensional Arrays
      4. Self-Test Questions
      5. Ragged Arrays (Optional)
    8. 7.6 Graphics Supplement
      1. Layout Panes
        1. The HBox Layout Pane
        2. The StackPane Layout
        3. The FlowPane Layout
        4. The GridPane Layout
        5. The BorderPane Layout
      2. Text Areas, Text Fields, and Combining Layouts
        1. Examples
        2. Examples
      3. Self-Test Questions
      4. Drawing Polygons
        1. Syntax
        2. Examples
        3. Syntax
        4. Example
        5. Syntax
        6. Example
      5. Self-Test Question
    9. Chapter Summary
      1. Exercises
    10. Practice Programs
    11. Programming Projects
  16. 8 Inheritance, Polymorphism, and Interfaces
    1. Objectives
    2. Prerequisites
    3. 8.1 Inheritance Basics
      1. Derived Classes
        1. Syntax
        2. Example:
      2. Overriding Method Definitions
      3. Overriding Versus Overloading
      4. The final Modifier
      5. Private Instance Variables and Private Methods of a Base Class
      6. UML Inheritance Diagrams
      7. Self-Test Questions
    4. 8.2 Programming with Inheritance
      1. Constructors in Derived Classes
        1. Example
      2. The this Method—Again
      3. Calling an Overridden Method
        1. Syntax
        2. Example
      4. Another Way to Define the equals Method in Undergraduate
      5. Type Compatibility
      6. Self-Test Questions
      7. The Class Object
      8. Self-Test Questions
      9. A Better equals Method
    5. 8.3 Polymorphism
      1. Dynamic Binding and Inheritance
      2. Dynamic Binding with toString
      3. Self-Test Questions
    6. 8.4 Interfaces and Abstract Classes
      1. Class Interfaces
      2. Java Interfaces
        1. Syntax
        2. Example
      3. Implementing an Interface
      4. An Interface as a Type
      5. Self-Test Questions
      6. Extending an Interface
      7. Self-Test Questions
      8. Self-Test Questions
      9. Abstract Classes
      10. Self-Test Questions
    7. 8.5 Graphics Supplement
      1. Event-Driven Programming
      2. Event Handling in a Separate Class
      3. Event Handling in the Main GUI Application Class
      4. Event Handling in an Anonymous Inner Class
      5. Self-Test Questions
    8. Chapter Summary
      1. Exercises
    9. Practice Programs
    10. Programming Projects
  17. 9 Exception Handling
    1. Objectives
    2. Prerequisites
    3. 9.1 Basic Exception Handling
      1. Exceptions in Java
        1. Syntax
        2. Example
      2. Self-Test Questions
      3. Predefined Exception Classes
      4. Self-Test Questions
    4. 9.2 Defining Your Own Exception Classes
      1. Guidelines
      2. Example
      3. Self-Test Questions
    5. 9.3 More About Exception Classes
      1. Declaring Exceptions (Passing the Buck)
        1. Syntax
        2. Example
      2. Kinds of Exceptions
      3. Errors
      4. Multiple Throws and Catches
      5. Self-Test Questions
      6. The finally Block
      7. Rethrowing an Exception (Optional)
      8. Self-Test Questions
      9. Self-Test Questions
    6. 9.4 Graphics Supplement
      1. Additional User Interface Controls and Shapes
      2. Images and Shapes
      3. Handling Mouse Events
      4. The Timeline Class
      5. Self-Test Questions
    7. Chapter Summary
      1. Exercises
    8. Practice Programs
    9. Programming Projects
  18. 10 Streams, File I/O, and Networking
    1. Objectives
    2. Prerequisites
    3. 10.1 An Overview of Streams and File I/O
      1. The Concept of a Stream
      2. Why Use Files for I/O?
      3. Text Files and Binary Files
      4. Self-Test Questions
    4. 10.2 Text-File I/O
      1. Creating a Text File
        1. Syntax
        2. Example
      2. Appending to a Text File
        1. Syntax
        2. Example
      3. Self-Test Questions
      4. Reading from a Text File
        1. Syntax
        2. Example
      5. Self-Test Questions
    5. 10.3 Techniques for Any File
      1. The Class File
      2. Using Path Names
      3. Methods of the Class File
        1. Example
      4. Self-Test Question
      5. Defining a Method to Open a Stream
    6. 10.4 Basic Binary-File I/O
      1. Creating a Binary File
      2. Writing Primitive Values to a Binary File
        1. Syntax
        2. Example
      3. Self-Test Questions
      4. Writing Strings to a Binary File
      5. Some Details About writeUTF
      6. Reading from a Binary File
        1. Syntax
        2. Example
      7. Self-Test Questions
      8. The Class EOFException
      9. Self-Test Questions
    7. 10.5 Binary-File I/O with Objects and Arrays
      1. Binary-File I/O with Objects of a Class
      2. Some Details of Serialization
      3. Array Objects in Binary Files
      4. Self-Test Questions
    8. 10.6 Network Communication with Streams
      1. Self-Test Questions
    9. 10.7 Graphics Supplement
    10. Chapter Summary
      1. Exercises
    11. Practice Programs
    12. Programming Projects
  19. 11 Recursion
    1. Objectives
    2. Prerequisites
    3. 11.1 The Basics of Recursion
      1. How Recursion Works
      2. Infinite Recursion
      3. Self-Test Questions
      4. Recursive Methods Versus Iterative Methods
      5. Recursive Methods That Return a Value
      6. Self-Test Questions
    4. 11.2 Programming with Recursion
      1. Self-Test Question
      2. Self-Test Questions
      3. Self-Test Questions
    5. 11.3 Graphics Supplement
      1. Lambda Functions and Event Handlers
      2. Self-Test Question
    6. Chapter Summary
      1. Exercises
    7. Practice Programs
    8. Programming Projects
  20. 12 Dynamic Data Structures and Generics
    1. Objectives
    2. Prerequisites
    3. 12.1 Array-Based Data Structures
      1. The Class ArrayList
      2. Creating an Instance of ArrayList
        1. Syntax
        2. Examples
      3. Using the Methods of ArrayList
      4. Self-Test Questions
      5. Parameterized Classes and Generic Data Types
      6. Self-Test Questions
    4. 12.2 The Java Collections Framework
      1. The Collection Interface
      2. The Class HashSet
      3. The Map Interface
      4. The Class HashMap
      5. Self-Test Questions
    5. 12.3 Linked Data Structures
      1. The Class LinkedList
      2. Self-Test Question
      3. Linked Lists
      4. Implementing the Operations of a Linked List
      5. Self-Test Questions
      6. A Privacy Leak
      7. Inner Classes
      8. Node Inner Classes
      9. Iterators
      10. Self-Test Questions
      11. The Java Iterator Interface
      12. Exception Handling with Linked Lists
      13. Self-Test Questions
      14. Variations on a Linked List
      15. Other Linked Data Structures
    6. 12.4 Generics
      1. The Basics
        1. Example
        2. Example
      2. Self-Test Questions
    7. 12.5 Graphics Supplement
      1. Building JavaFX Applications with the Scene Builder
      2. Self-Test Questions
      3. Where to Go from Here
    8. Chapter Summary
      1. Exercises
    9. Practice Programs
    10. Programming Projects
  21. Appendix 1 Getting Java
  22. Appendix 2 Running Applets
  23. Appendix 3 Protected and Package Modifiers
  24. Appendix 4 The DecimalFormat Class
  25. Appendix 5 Javadoc
  26. Appendix 6 Differences Between C++ and Java
  27. Appendix 7 Unicode Character Codes
  28. Appendix 8 Introduction to Java 8 Functional Programming
  29. Appendix 9 The Iterator Interface
  30. Appendix 10 Cloning
  31. Appendix 11 Java Reserved Keywords
  32. Credits
    1. Online Chapters:
  33. Index
    1. Symbols
    2. A
    3. B
    4. C
    5. D
    6. E
    7. F
    8. G
    9. H
    10. I
    11. J
    12. K
    13. L
    14. M
    15. N
    16. O
    17. P
    18. Q
    19. R
    20. S
    21. T
    22. U
    23. V
    24. W
    25. X
    26. Y
    27. Z

Product information

  • Title: Java: An Introduction to Problem Solving and Programming, 8th Edition
  • Author(s): Walter Savitch
  • Release date: February 2017
  • Publisher(s): Pearson
  • ISBN: 9780137464159