- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Which attributes have added to @Deprecated annotation in Java 9?
There are two new parameters or attributes added to @Deprecated annotation in Java 9. Those parameters are Since and forRemoval, both of these two parameters are optional with a default value when we can't specify it.
Since
This string parameter specifies the version in which the API became deprecated. The default value of this element is an empty string.
Syntax
@Deprecated(since="<version>")
forRemoval
This boolean parameter specifies whether the API is intended to be removed in a future release or not. The default value is false when we can't specify it.
Syntax
@Deprecated(forRemoval=<boolean>)
Example
public class DeprecatedAnnotationTest { public static void main(String[] args) { DeprecatedAnnotationTest test = new DeprecatedAnnotationTest(); test.method1(); test.method2(); } @Deprecated(since="7.0") public void method1() { System.out.println("@Deprecated(since=\"7.0\")"); } @Deprecated(since="5.0", forRemoval=true) public void method2() { System.out.println("@Deprecated(since=\"5.0\", forRemoval=true)"); } }
Output
@Deprecated(since="7.0") @Deprecated(since="5.0", forRemoval=true)
- Related Articles
- What are the improvements for @Deprecated annotation in Java 9?
- Which factory methods have added for collections in Java 9?
- What are new methods have added to the Arrays class in Java 9?
- @SafeVarargs annotation for private methods in Java 9?
- How to print all attributes in StackFrame API in Java 9?
- What are the new features added to Stream API in Java 9?
- What are the new methods added to Process API in Java 9?
- What are new methods added to the String class in Java 9?
- When to use @JsonAutoDetect annotation in Java?
- What are the new methods added to an Optional class in Java 9?
- Importance of @Override annotation in Java?
- Importance of @JsonFilter annotation in Java?
- When to use @JsonValue annotation using Jackson in Java?
- When to use @ConstructorProperties annotation with Jackson in Java?
- What to use @SerializedName annotation using Gson in Java?

Advertisements