Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!

Harry Tuttle

+ Follow
since Apr 08, 2010
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Harry Tuttle

Steve Luke wrote:

Harry Tuttle wrote:I found some explanations here

That link provides good information, but in addition to that, for some reason you put the Total report inside your catch(InterruptedException) clause. notifyAll() does not interrupt wait(), it notifies it that it should stop normally, ergo the Total report should not get called (unless some other interruption occurred). You do not want the report in the catch clause, you want it either just after the wait() (at the end of the try clause) or just after the catch clause.

Thank you. In this case I must say, you can learn from errors!
I try to run the example Reader / Calculator on page 753 of the scjp book. here is the code for the Reader class

and the Calculator class

When I run these classes only the waiting prompt is shown but not the total. What's wrong?

I found some explanations here

Harry Tuttle wrote:... and the following code on page 679 is quite clear to me

The statement above is wrong!

Martin Vajsar wrote:On line 8 you call bar.doStuff(), but this method does nothing (it's empty - see its definition on line 24). You probably intended (but forgot) to call f.foof() in the Bar.doStuff.method.

You're right. Now also the string "foofy" is prompted!
8 years ago
I'm just reading chapter 8 "Inner classes" in my SCJP book (from Sierra and Bates) and the following code on page 679 is quite clear to me

To test the argument-defined anonymous inner class Foo() a inserted the code between the comments start and end added code. The problem is, when I run the code above the string "foofy" is not printed. What's wrong here?
8 years ago

I'm just preparing for the scjp/ocp and in the chapter about the inner classes (SCJP Sun Certified Programmer for Java 6 Study Guide I, p. 670) there is this code example:

I understand all lines, but my question is: It's right that the inner object will be carbage collected (but with no garantee) after the method doStuff() completes?

8 years ago
hello everybody
I'm just a little confused about table 7-2 at page 565 in the book: this table hasn't the same content like the one in the ch07.pdf

I guess, the one in the book is ok and the one in the file is wrong: 1) capitalized T in Hashtable 2) HashTable is listed twice and 3) Hashmap is not listed.
It's possible to develop apps for my device with a android platform 2.3 with a android sdk 4.0.2? are there problems that I have to pay a special attention?
8 years ago

William Brogden wrote:What does the URL that works on the browser look like?

Where, exactly, do you get this error message?


this is the method to initialize the cam

the ml, ds and player are fields of the class. and here is the output of the printStackTrace():

9 years ago

as a java developer i want to make a connection to my webcam from java using the java media framework. and here is my problem: when i create an instance of MediaLocator i use the same url my brower use to display the video image, but this url cause an error "The URL may not exist. Please check URL". i can't figure out what's going wrong. any ideas how the url must look?
9 years ago

hello, there is no logic using > to compare two objects?! so your item should have a get-method that returns the value you want to compare.
9 years ago

I'm running Apache Tomcat 7.0.8 on a Wintel machine. In the base directory of Tomcat there is a RUNNING.txt file saying

Unpack the binary distribution into a convenient location so that the
distribution resides in its own directory (conventionally named

I don't find the above suggestion is a good idea (to implement the [version] in the path-name), because when the version is epdated there is a huge of work changing path name in the environment variables, service and so on. how do you handle this? In unix changing one link would be enough, but on Windows?
9 years ago

Stephan van Hulst wrote:Harry, sorry for nitpicking (again), but objects may be eligible for collection even if they have references to them. What you mean is *reachable references*, which is an important difference. If two objects reference eachother, but nothing else does, they may still be garbage collected because they are not reachable.

no problem. this page explain the types of reference objects.

Jan tenpas wrote:When line 16 is reached, how many objects will be eligible for garbage collection?

Answer: 1

hello jan, i had the same question some monthes ago. the rule you must apply here is that an object is only eligible by the gc when it has no references on it. perhaps to understand this gc problem it helps you to differentiate between stack and heap. the stack is a piece of memory where all references to objects are stored. the heap is a piece of memory where the objects live.

in the given code four objects are instantiated, lets call them A1, A2, B1 and B2. the object B1 is referenced by b1, A1.b1 and A1.b2. so B1 will not be eligible by nulling b1, because the other references are still there. B2 has two references on it, on by b2 and the other by A2.b2. so even by nulling the b2 there is still one reference on it, so this object will not be eligible. the next object is A1 that has only one reference from a1. so by nulling a1 this object will be eligible by the gc. the last object is A2 that has also only one reference from a2. but this reference is not set to null so also this object is not eligible for the gc. so looking once again at the four objects we can see that only 1 object is eligible. so the answer given in the book is right if you need further help, let me know.

Harry Tuttle wrote:
I have a html-file named index.html with a send button that runs on Apache TomCat 7.0.2. When the send button is pushed a Servlet class named TestServlet should be executed, here call in the html-file

i could fix the problem by modifying the above form action in

where mywebapp is the name of my web-application.
9 years ago