Enhanced Deprecation annotation in Java9

Views: 108   

Java9 enhanced @Deprecated annotation to make you add the version from which the depreciation started and also whether or not that will be removed in future releases. Following example shoes you how to use both of them

public class ClassContainingDeprecatedMethods {

    @Deprecated(since = "1.9", forRemoval = true)
    public void someDeprecatedMethod() {

    }
}

In the following example the method someDeprecatedMethod() is deprecated from version 1.9 and that will be removed in future releases.

On By