Frequently Asked Questions
This document contains answers to some frequency (and infrequently) asked questions.
Why Java? Why not C or C++ or C# or Python or Ruby or Matlab? The program that we are writing are very similar to their counterparts in several other languages, so our choice of language is not crucial. We use Java because it is widely available, widely used, embraces a full set of modern abstractions, and has a variety of automatic checks for mistakes in programs, so it works well for students learning to program. There is no perfect language and you certainly will find yourself programming in other languages in the future.
Do I need previous programming experience? No, this textbook starts from the beginning. If you have prior programming experience, you can move through Chapter 1 at a more rapid pace, but you are likely to find the examples worthy of careful study.
Do I need any special math or science background? No, we assume only a basic high school background. Our approach reinforces and takes advantage of students' preparation in high-school math and science as they learn programming.
Are there solutions to all of the exercises? No, we've linked to the ones we have written. Feel free to contribute to the community and submit a solution to one of the exercises.
I'm an instructor. Can I use your material for my class? If you adopt the book, you are free to use and adapt any of the material for your needs. Otherwise, please email the authors to request permission.
How can I contact the authors? Email Kevin Wayne.
Which textbook do you recommend for CS 2 course? We highly recommend the companion textbook Algorithms, 4th Edition.
Which version of Java are you using? Java 8 (or newer).
Who designed Java? James Gosling. Here is an interview, where he discusses some of the thoughts that went into including and not including certain features of Java.
Is there an official specification of the Java language? Yes, but it's quite technical. Here is the Java Language and Virtual Machine Specifications.
Where can I find documentation for the Java libraries? Here is documentation for all Java 8 classes. As you become a more proficient Java programmer, this will become an essential reference.
Can you recommend a good intermediate-level book on Java? Check out Oracle's online Java Tutorial for an introduction to advanced Java features not covered in our textbook. Joshua Bloch's Effective Java is a "must-read" for any intermediate to advanced Java programmer.
I've programmed in C before. Can you offer any help on transitioning? Here's a comparison table.
Is there a good integrated development environment for novices? We recommend Dr. Java. More sophisticated IDEs, such as Eclipse, are overkill for an intro course, but are widely used by professional programmers.
Should I use a debugger? Reasonable people disagree on this one. Our preference is not to use a debugger when first learning to program.
Are there tools for detecting common bugs? FindBugs is one such tool that we recommend.
How do I set the classpath? The classpath is an environment variable which javac and java use to find the location of any needed .class files. This would enable you to put StdDraw.class, StdIn.class, and other commonly used libraries and they would always be available. By default, the classpath is the current working directory. If your classpath has already been set, you may need to change it to make it include the current working directory. Here's a wealth of classpath info. It can be rather confusing.
How does Java compare in terms of speed to C or C++? To Perl or Python? The answer depends greatly on the type of application you're running. As a rule of thumb, Java's performance is good, C and C++ are blazingly fast, and Perl/Python are slow. This article claims that Java is comparable to C for scientific applications involving number crunching. No benchmark is perfect, but The Computer Language Shootout Benchmarks is a good starting point.
Are there are common pitfalls that I should be aware of? Here's a worthwhile list of common Java gotchas.
Does Java have pointers? Java doesn't have raw pointers like C or C++, but it has references which are almost as powerful, but much safer. Here's a good summary of the differences. The Java Virtual Machine itself can implement references with pointers (for raw speed) or with handles (for more flexible memory management).
The program links contain syntax-highlighted versions of the code. How was this accomplished? We use GNU source-highlight to automatically produce the syntax-highlighted versions.
How did you create the screen output drawings in the textbook?
We used our standard drawing library described in the textbook.