4.7. FAQ¶
What is the difference between
throw,throws, and@throws?The
throwkeyword is used in a block of code to explicitly throw an exception. This is desirable when you want your method to throw an exception under some predefined conditions. If the exception object being thrown usingthrowis a checked exception, then you might also need to includethrowsin the method signature.The
throwskeyword is used in a method or constructor signature to list the checked exceptions that the method is allowed to propagate.The
@throwstag is a Javadoc tag that is used in the Javadoc comment associated with a method (or constructor) to document that it can throw an exception under certain circumstances. The rule of thumb is this: if your method throws an exception (checked or unchecked) that a user of your method should handle, then you should document that exception using@throwsin the associated Javadoc comment.
How do I update the documentation website?
To update the documentation website, rerun the same
javadoccommand you used to originally generate the website from the same directory. You should not need to recreate the symbolic link.More details found here under “Updating the Website”.
Why not tell
javadocto generate the API documentation website directly in~/public_html/cs1302-javadoc-docinstead ofdoc?That is definitely an option, assuming the
~/public_html/cs1302-javadoc-docdirectory already exists. We chose the symbolic link approach in the tutorial because it helps keep thejavadoccommand nice and short and to provide an example of a symbolic link.Why not use
cpormvto copy or move (respectively) the generated API documentation website directly to~/public_html/cs1302-javadoc-docinstead usingln?Since our use of
lncreated a symbolic link to thedocdirectory, we can now regenerate the API documentation website indocand have those changes be automatically reflected in~/public_html/cs1302-javadoc-doc. Also, from an organizational standpoint, it makes sense to have the documentation contained within the main project directory.