I would like to know the best way to add a comment to identify a deprecated class in Java. Should I remove the previous comment added to the top of the class that helps another programmer to know what was that class for, or should I add it below the comment?
The recommended approach to deprecating a class, method, or field in Java is to use the
@Deprecated annotation, which became available in Java 5, or the
@deprecated JavaDoc tag, which has been around since Java 1.1. Oracle has a document about the specifics on how and when to deprecate APIs that appears to be relevant.
Should i remove the previous comment added to the top of the class that helps another programmer to know what was that class for or add it below the comment?
You should not edit or remove any existing comments, other than to add the JavaDoc tag or annotation. Deprecated code might still be in use in legacy systems, and developers of those systems need to have access to the documentation that the original developers did in some form.