This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
It would be of tremendous help if you posted the exact error you get when you run your code. It makes it easier for dumb people like me to zero in on where the problem is, without having to copy your code, paste it into a document, compile it, and run it (which is what I did).
Once I did that, I saw this error:
Exception in thread "main" java.lang.NoSuchMethodError: main
Seeing that tells me there is a problem with your main method.
Now I know exactly where to look. The main method in this code looks like this:
When you start a java program, it is looking for a main with a signiature of this:
If you simply put in that argument to your main method, the code will run.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
For the record, here is the code you originally posted, then deleted:
Joined: Oct 13, 2005
Not quite sure how Fred found the code you deleted; maybe he was just there in the 5 minutes it was visible. That example shows how bad it can be to delete old posts or parts of them; the remainder of the thread reads like nonsense.
I don't see how comments such as:
// Instance data
help to clarify the code. The fact that it is an instance variable/constructor/getter is made clear by the definition of it. You don't need the comment at all. In fact now you have 2 parts to change if you want to change something. The method definition and the comment. If you forget to change one then voila: confusion.
I can somewhat understand the following comment:
// Implementations of abstract methods.
But Java contains a special annotation for that: @Override. It even has a bonus. If the method doesn't override/implement a method then the compiler will complain.