Stay organized with collections
Save and categorize content based on your preferences.
Deprecated
public
abstract
@interface
Deprecated
implements
Annotation
A program element annotated @Deprecated
is one that programmers
are discouraged from using. An element may be deprecated for any of several
reasons, for example, its usage is likely to lead to errors; it may
be changed incompatibly or removed in a future version; it has been
superseded by a newer, usually preferable alternative; or it is obsolete.
Compilers issue warnings when a deprecated program element is used or
overridden in non-deprecated code. Use of the @Deprecated
annotation on a local variable declaration or on a parameter declaration
or a package declaration has no effect on the warnings issued by a compiler.
When a module is deprecated, the use of that module in requires
, but not in exports
or opens
clauses causes
a warning to be issued. A module being deprecated does not cause
warnings to be issued for uses of types within the module.
This annotation type has a string-valued element since
. The value
of this element indicates the version in which the annotated program element
was first deprecated.
This annotation type has a boolean-valued element forRemoval
.
A value of true
indicates intent to remove the annotated program
element in a future version. A value of false
indicates that use of
the annotated program element is discouraged, but at the time the program
element was annotated, there was no specific intent to remove it.
Summary
Public methods |
boolean
|
forRemoval()
Indicates whether the annotated element is subject to removal in a
future version.
|
String
|
since()
Returns the version in which the annotated element became deprecated.
|
Public methods
forRemoval
public boolean forRemoval ()
Indicates whether the annotated element is subject to removal in a
future version. The default value is false
.
Returns |
boolean |
whether the element is subject to removal |
since
public String since ()
Returns the version in which the annotated element became deprecated.
The version string is in the same format and namespace as the value of
the @since
javadoc tag. The default value is the empty
string.
Returns |
String |
the version string |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# Deprecated\n\nAdded in [API level 1](/guide/topics/manifest/uses-sdk-element#ApiLevels) \nSummary: [Methods](#pubmethods) \\| [Inherited Methods](#inhmethods) \n\nDeprecated\n==========\n\n\n`\npublic\n\n\nabstract\n@interface\nDeprecated\n`\n\n\n`\n\n\nimplements\n\n`[Annotation](/reference/java/lang/annotation/Annotation)`\n\n\n`\n\n|----------------------|\n| java.lang.Deprecated |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nA program element annotated `@Deprecated` is one that programmers\nare discouraged from using. An element may be deprecated for any of several\nreasons, for example, its usage is likely to lead to errors; it may\nbe changed incompatibly or removed in a future version; it has been\nsuperseded by a newer, usually preferable alternative; or it is obsolete.\n\nCompilers issue warnings when a deprecated program element is used or\noverridden in non-deprecated code. Use of the `@Deprecated`\nannotation on a local variable declaration or on a parameter declaration\nor a package declaration has no effect on the warnings issued by a compiler.\n\nWhen a module is deprecated, the use of that module in `requires`, but not in `exports` or `opens` clauses causes\na warning to be issued. A module being deprecated does *not* cause\nwarnings to be issued for uses of types within the module.\n\nThis annotation type has a string-valued element `since`. The value\nof this element indicates the version in which the annotated program element\nwas first deprecated.\n\nThis annotation type has a boolean-valued element `forRemoval`.\nA value of `true` indicates intent to remove the annotated program\nelement in a future version. A value of `false` indicates that use of\nthe annotated program element is discouraged, but at the time the program\nelement was annotated, there was no specific intent to remove it.\n\nSummary\n-------\n\n| ### Public methods ||\n|------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` boolean` | ` `[forRemoval](/reference/java/lang/Deprecated#forRemoval())`() ` Indicates whether the annotated element is subject to removal in a future version. |\n| ` `[String](/reference/java/lang/String) | ` `[since](/reference/java/lang/Deprecated#since())`() ` Returns the version in which the annotated element became deprecated. |\n\n| ### Inherited methods |\n|-----------------------|---|\n| From interface ` `[java.lang.annotation.Annotation](/reference/java/lang/annotation/Annotation)` ` |-------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract `[Class](/reference/java/lang/Class)`\u003c? extends `[Annotation](/reference/java/lang/annotation/Annotation)`\u003e` | ` `[annotationType](/reference/java/lang/annotation/Annotation#annotationType())`() ` Returns the annotation interface of this annotation. | | ` abstract boolean` | ` `[equals](/reference/java/lang/annotation/Annotation#equals(java.lang.Object))`(`[Object](/reference/java/lang/Object)` obj) ` Returns true if the specified object represents an annotation that is logically equivalent to this one. | | ` abstract int` | ` `[hashCode](/reference/java/lang/annotation/Annotation#hashCode())`() ` Returns the hash code of this annotation. | | ` abstract `[String](/reference/java/lang/String) | ` `[toString](/reference/java/lang/annotation/Annotation#toString())`() ` Returns a string representation of this annotation. | ||\n\nPublic methods\n--------------\n\n### forRemoval\n\nAdded in [API level 31](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic boolean forRemoval ()\n```\n\nIndicates whether the annotated element is subject to removal in a\nfuture version. The default value is `false`.\n\n\u003cbr /\u003e\n\n| Returns ||\n|-----------|--------------------------------------------------|\n| `boolean` | whether the element is subject to removal \u003cbr /\u003e |\n\n### since\n\nAdded in [API level 31](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic String since ()\n```\n\nReturns the version in which the annotated element became deprecated.\nThe version string is in the same format and namespace as the value of\nthe `@since` javadoc tag. The default value is the empty\nstring.\n\n\u003cbr /\u003e\n\n| Returns ||\n|---------------------------------------|---------------------------|\n| [String](/reference/java/lang/String) | the version string \u003cbr /\u003e |"]]