Home > Articles

  • Print
  • + Share This
This chapter is from the book


  • Q. I tried to use StdRandom, but got the error message Exception in thread "main" java.lang.NoClassDefFoundError: StdRandom. What’s wrong?

  • A. You need to make StdRandom accessible to Java. See the first Q&A at the end of SECTION 1.5.

  • Q. Is there a keyword that identifies a class as a library?

  • A. No, any set of public methods will do. There is a bit of a conceptual leap in this viewpoint because it is one thing to sit down to create a .java file that you will compile and run, quite another thing to create a .java file that you will rely on much later in the future, and still another thing to create a .java file for someone else to use in the future. You need to develop some libraries for your own use before engaging in this sort of activity, which is the province of experienced systems programmers.

  • Q. How do I develop a new version of a library that I have been using for a while?

  • A. With care. Any change to the API might break any client program, so it is best to work in a separate directory. When you use this approach, you are working with a copy of the code. If you are changing a library that has a lot of clients, you can appreciate the problems faced by companies putting out new versions of their software. If you just want to add a few methods to a library, go ahead: that is usually not too dangerous, though you should realize that you might find yourself in a situation where you have to support that library for years!

  • Q. How do I know that an implementation behaves properly? Why not automatically check that it satisfies the API?

  • A. We use informal specifications because writing a detailed specification is not much different from writing a program. Moreover, a fundamental tenet of theoretical computer science says that doing so does not even solve the basic problem, because generally there is no way to check that two different programs perform the same computation.

  • + Share This
  • 🔖 Save To Your Account