Frequently Asked Questions


This document contains answers to some frequency (and infrequently) asked questions.


General Questions


What is the differene between the textbooks Introduction to Programming in Java and Computer Science? The Computer Science book contains the Java book as its first four chapters. It adds chapters on theory, machines, and architecture.

Why Java? Why not C or C++ or C# or Python or Ruby or Matlab? The programs 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.

I discovered what I think is a typo or error. Who should I contact? Please check the errata list and fill out a bug submission form. We appreciate your feedback.

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.


Java


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 our custom IntelliJ-based programming environment for Mac OS X, Windows, or Linux.

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? SpotBugs is one such tool that we recommend.

Is there a list of Java error messages? Here's an index of compile-time error messages and their likely causes. Here's an index of run-time error messages and their likely causes.

Is there an open source version of the Java libraries? Yes, OpenJDK. Here's a good description of open source software.

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).



Creating the Booksite


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.