The Java Course provides a general introduction to programming in Java. It is based on A.B. Downey's book, How to Think Like a Computer Scientist. Click here for details.


In the last section I mentioned "all the things methods are good for." About this time, you might be wondering what exactly those things are. Here are some of the reasons methods are useful:

  • By giving a name to a sequence of statements, you make your program easier to read and debug.
  • Dividing a long program into methods allows you to separate parts of the program, debug them in isolation, and then compose them into a whole.
  • Methods facilitate both recursion and iteration.
  • Well-designed methods are often useful for many programs. Once you write and debug one, you can reuse it.

Last Update: 2011-01-24