WHAT YOU WILL LEARN IN THIS CHAPTER:
- What kinds of errors can occur in programming
- How to find errors in your program
- How to handle exceptions that could crash your program
- How to test your program
WROX.COM CODE DOWNLOADS FOR THIS CHAPTER
The wrox.com code downloads for this chapter are found at
www.wrox.com/go/beginningjavaprogramming on the Download Code tab. The code is in the Chapter 6 download and individually named according to the names throughout the chapter.
You are now midway through this book. You’ve learned the basics of Java and programming already. In the following chapters, you’ll be going more in depth with object-oriented programming and interacting with users and data sources outside your Java program. This chapter is placed in between to offer you the tools and techniques needed to handle many of the errors that might begin to pop up as your programs start to become more complex. The chapter is divided into three main sections: types of errors, testing options, and programming styles. You saw the concepts introduced as early as Chapter 1, but here you will see actual solutions put into practice with a chance to try them out on your own. By the end of this chapter, you should have developed the skills to avoid errors while you program and to find and fix the errors that will still inevitably occur.
RECOGNIZING ERROR TYPES
Errors are almost unavoidable when programming. Just as when you are writing an essay ...