Is it wrong to use Deprecated methods or classes in Java?

1. Is it wrong to use Deprecated methods or classes in Java?

From the definition of deprecated:

A program element annotated @Deprecated is one that programmers are discouraged from using, typically because it is dangerous, or because a better alternative exists.

The method is kept in the API for backward compatibility for an unspecified period of time, and may in future releases be removed. That is, no, it’s not wrong, but there is a better way of doing it, which is more robust against API changes.

2. What if I don’t change any method and run my application with warnings that I have, will it create any performance issue.

Most likely no. It will continue to work as before the deprecation. The contract of the API method will not change. If some internal data structure changes in favor of a new, better method, there could be a performance impact, but it’s quite unlikely.


The funniest deprecation in the Java API, is imo, the FontMetrics.getMaxDecent. Reason for deprecation: Spelling error.

Deprecated. As of JDK version 1.1.1, replaced by getMaxDescent().

Leave a Comment