I have the following method:
@Override
public boolean myMethod()
{
// do stuff
}
If I want to add a javadoc for this method, is there any convention on how to do this along with having the @Override annotation (or any other annotation)?
The reason I ask is because I’ve read that javadoc comments MUST be directly before the method (no newlines between the two), and I’m not sure if putting the javadoc comment directly above the @Override annotation would mess things up.
Would this be the conventional way to do it for instance? Does this work?
/**
* This is my method's javadoc comment.
*/
@Override
public boolean myMethod()
{
// do stuff
}
Yes, this way is the right way, I didn’t see yet the other way around. And yes, this way it works. Didn’t try the other way around.
But basically I usually wouldn’t add a javadoc comment to a method that overrides another method, especially when implementing interfaces. The tag
@inheritDocis helpful here, to distribute the documentation without big efforts. But that is specific to this example, you might add other annotations, too.