Contents

List of examples

Preface to the second edition

Chapter summary

Review board

PART 1 Fundamentals 1

Chapter 1 Introduction

1.1 Welcome to Java
1.2 Software development
1.3 The approach of this book
1.4 Getting started with Java
1.5 The Java Gently web site
Summary
Quiz: to get you started

Chapter 2 Simple programs

2.1 Two starter programs
2.2 Fundamentals of object-oriented programming
2.3 Beginning with output
2.4 All about assignment
2.5 Using classes and objects
Summary
Quiz
Problems

Chapter 3 Structuring

3.1 Properties of a good program
3.2 Talking about types
3.3 Repetition with for-loops
3.4 Making methods
3.5 Passing parameters
3.6 Guidelines for designing classes
3.7 Case Study 1: Price tickets
Summary
Quiz
Problems

Chapter 4 Changing the state

4.1 Inputting interactively
4.2 File input and output
4.3 Selection with if-else
4.4 Introduction to exceptions
4.5 Creating and accessing packages
Summary
Quiz
Problems

Chapter 5 Controlling the flow

5.1 Conditional loops with while and do
5.2 The switch-statement
5.3 Conditional loops and input data
5.4 Case Study 2: Rock–scissors–paper game
Summary
Quiz
Problems

Chapter 6 Arrays and tables

6.1 Simple arrays
6.2 Tables
6.3 Sorting and searching
6.4 Dictionaries
Summary
Quiz
Problems

Chapter 7 Formatting

7.1 Strings and string handling
7.2 Tokenizers and the Text class
7.3 Formatting numbers with the java.text package
7.4 Dates, calendars and time
Summary
Quiz
Problems

PART II Power 1

Chapter 8 Objects at work

8.1 Object protection
8.2 Designing an object-oriented program
8.3 Properties of objects
8.4 Lists of objects
8.5 Inner classes
8.6 Case Study 3: Nelson’s Coffee Shop
Summary
Quiz
Problems

Chapter 9 Abstraction and inheritance

9.1 Class power
9.2 Abstraction through interfaces
9.3 Inheritance
9.4 Abstract methods and classes
9.5 Case Study 4: Veterinary tags
Summary
Quiz
Problems

Chapter 10 Graphical user interfaces

10.1 Introduction to the awt
10.2 Putting graphics in a window
10.3 Laying out buttons and other components
10.4 Panels and canvases for grouping
Summary
Quiz
Problems

Chapter 11 Event-driven programming

11.1 Interaction with text fields
11.2 Events, listeners and handlers
11.3 Managing sequences of events
11.4 Case Study 5: Supermarket till
Summary
Quiz
Problems

Chapter 12 Applets in action

12.1 From applications to applets
12.2 Applets in browsers
12.3 Sound and images
12.4 Case Study 6: The Nature Conservation Project
Summary
Quiz
Problems

Chapter 13 Multi-threading

13.1 Introduction to multi-threading
13.2 Setting up threads
13.3 Synchronization among threads
13.4 Case Study 7: Walkman hire
Summary
Quiz
Problems

Chapter 14 Networking

14.1 Connecting via URLs
14.2 Ports and sockets
14.3 Case Study 8: Chatter system
14.4 Database connectivity
14.5 Accessing remote objects
14.6 Case Study 9: The Airport Announcer system
Summary
Quiz
Problems

Chapter 15 Algorithms and data structures

15.1 About data structures
15.2 Linear and binary searching
15.3 Quicksort and performance
15.4 Stacks and queues
15.5 Linked lists again
15.6 Bit sets
Summary
Quiz
Problems

Answers to Quizzes

List of Syntax forms for Java

Index