Frequently asked questions:

Q: How do I deallocate / delete objects?

A: You don't. Java does the deallocation for you. The Java Virtual Machine (the program you invoke with java) runs a
     process in parallel with your program, and this process (called Garbage Collector) checks for memory no longer in use in
     your program and automagically frees that memory.

    For example, if you allocate a String inside a method, when the method terminates, the memory used by the String object
    will be freed. Similarly, when your program terminates, the List class will be deleted and so will all the Objects stored in the

    For more details, check out the Cleaning Up Unused Objects in the Java Language Tutorial at

Q: Do I need to catch exceptions in Program 2?

A: No. Program 2 is a rewrite of Program 1 using linked lists. Program 1 did not have to handle exceptional cases (such as
     going beyond the end of the list with nextElement()), not does Program 2 have to.

Q: How do I convert an integer to a String?

A: You can do it in at least two ways. Suppose s is declared as a String and i is of type int.

                   1.s = new Integer( i ).toString(); // make i into an Integer object, then
                                                       // use toString() on the object

                   2.s = "" + i; // the addition forces i to be converted to a String
                                  // since we add an empty string ( "" ), the result
                                  // string contains just the integer value

       If you know of more ways to do this, please let me know.

Q: I took some Computer Science classes a while ago. Now, whatever accounts I had there are expired. But in order to use
     the computers at CS for this course, I need to have a login... so what should I do?

A: Your account with the CS department should have been reactivated. Try logging in to one of the machines in the CS labs.

     If that does not work, or if you forgot your password, please go to the CSL office, 2350 Computer Sciences and
     Statistics, and have your account activated asap.