2.   Functions


In this chapter, we consider a concept that has as profound an impact on control flow as do conditionals and loops: the function, which allows us to transfer control back and forth between different pieces of code. Functions are important because they allow us to clearly separate tasks within a program and because they provide a general mechanism that enables us to reuse code.

Java programs in this chapter.

Below is a list of Java programs in this chapter. Click on the program name to access the Java code; click on the reference number for a brief description; read the textbook for a full discussion.

2.1.1 Newton.java Newton's method (revisited)
2.1.3 Coupon.java coupon collector (revisited)
2.2.1 StdRandom.java random number library
2.2.3 IFS.java iterated function systems
2.2.5 StdStats.java data analysis library
2.3.1 Euclid.java Euclid's algorithm
2.3.3 Beckett.java Gray code
2.3.5 Brownian.java Brownian bridge
2.4.2 VerticalPercolation.java vertical percolation
2.4.4 Estimate.java percolation probability estimate
2.4.6 PercPlot.java adaptive plot client
2body.txt 3body.txt 4body.txt 2bodyTiny.txt 4.1.1.java 41analysis


Include a link.