Mihai's CS368-1 (Fall 1999):
|
|
Mon Sep 20, 1999 Q:How do I deallocate / delete objects? |
| A:
You don't, as 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 list. For more details, check out the Cleaning Up Unused Objects in the Java Language Tutorial at http://java.sun.com/docs/books/tutorial/java/javaOO/garbagecollection.html. |
|
Mon Sep 20, 1999 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. |
|
Thu Sep 16, 1999 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.
|
|
Thu Sep 2, 1999 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. |