0

Why do we use methods which are deprecated? When are the deprecated method completely removed from being use. What is the backward compatibility limit?Or we support all deprecated method ever written?

Are the deprecated methods available forever? if not why not remove it completely after a certain time frame?

  • It's up to you… You can use them but the annotation means that using such a method is dangerous or just worse than using an non deprecated alternative. Keep in mind that there are always reasons for methods being annotated `@Deprecated`. – deHaar Oct 15 '19 at 08:26
  • 2
    Possible duplicate of [The constructor Date(...) is deprecated. What does it mean? (Java)](https://stackoverflow.com/questions/1999766/the-constructor-date-is-deprecated-what-does-it-mean-java) – deHaar Oct 15 '19 at 08:26
  • Sorry But I think the question you linked to is asking the meaning of deprecated annotation. The question I asked was more on the line of why do we use the annotation. And If we can remove the code completely ever once the deprecated code becomes very old. – Ajitav Basak Oct 16 '19 at 05:03

2 Answers2

2

Deprecation does not necessarily mean, that a function will be removed in the future. It just states that it is not recommended to use the function because better alternatives are available. The time frame when and why parts of the API are removed depends from case to case. If for example a function is completely useless and nearly nobody uses it the barrier for deletion is much lower than for a commonly used part of the API.

The Java Language Specification describes the @Deprecated annotation as follows:

A program element annotated @Deprecated is one that programmers are discouraged from using, typically because it is dangerous, or because a better alternative exists. Compilers warn when a deprecated program element is used or overridden in non-deprecated code.

Jannik
  • 1,583
  • 1
  • 14
  • 22
0

It depends on you, sometimes we do not delete the @Deprecated method because the method might be used in your project. If the @Deprecated method does not used required anymore in the sense you can remove/delete the method.

Ashok kumar Ganesan
  • 1,098
  • 5
  • 20
  • 48
huxd
  • 1
  • 2