Originally posted by Timothy Sam:
First, it instantiates a String like
mesage=new String("Hello, ");
which should have just been
message = "Hello, ";
Both will work - given the circumstances I would have preferred the second one. The "Hello, " string literal goes into the string pool were it can be reused (remember Strings are immutable). The second version references that string literal directly. The first version creates another, separate string object (copying the string literal) which is entirely unnecessary
Second, the article says "The implementation class also must define a default, public, no-argument constructor."
But there's no public constructor there but a method
public void Hello() {}
You are correct that is not a constructor. The "void" its the dead giveaway. However there is a "default, public, no-argument constructor". You may remember from your SCJP preparation: the Java compiler will add a "public, no-argument constructor" if there is no other constructor present.
The annotations also has open-close parenthesis which makes me wonder... Is there something wrong here?
The annotation looks ok. The parenthesis actually have a use under different circumstances. See:
The Java Tutorials: Annotations