[ Back to: Java in a Nutshell, Third Edition ]The Java programming examples linked below are from the book Java in a Nutshell, Third Edition, by David Flanagan, published by O'Reilly & Associates.
Note: The code in these example archives may not match the examples in the latest print copy of the book. Please check the posted errata for discrepancies be tween the book and online errata. We apologize for the inconvenience.
If you are looking for the examples from the *second* edition of Java in a Nutshell, click here.
If you are looking for the examples from the *first* edition of Java in a Nutshell, click here.
Although you can view the example source code online, by following the links below, I recommend that you download the complete set of examples so that you can work with them on your computer locally. They are available as a zip file.
You may study, use, and modify these examples for any purpose. This means that you can use the examples, or modified versions of the examples in your programs, and you can even sell those programs. You can distribute the source code to these examples, but only for non-commercial purposes, and only as long as the copyright notice is retained. This means that you can make them available on a public Web site, for example, but that you cannot include them on a commercial CD-ROM without the prior permission of O'Reilly and Associates.
Note that these examples are provided AS-IS, with absolutely NO WARRANTY of any kind, either expressed or implied.
The filenames identify each example by its chapter number and example number. Example 1-1 is a complete Java program, and is also provided in a file named Factorial.java. As explained in Chapter 1, you can compile and run this program with commands like these:
java Factorial 4
None of the remaining examples have main() methods, so they are not complete programs, and can not be run by themselves. Many of these examples do define Java classes, and, if appropriately renamed, they can be compiled, and used by other Java classes. (Although none of them are particularly useful!). Other examples are simply code fragments, which can be incorporated into other Java code, but which cannot be compiled as is.
[ Back to: Java in a Nutshell, Third Edition ]
© 2001, O'Reilly & Associates, Inc.