Wednesday, April 27, 2011

Deprecated annotation

Deprecated is a marker annotation type that can be applied to a method or a type (class/interface) to
indicate that the method or type is deprecated. Deprecating a method:

public class DeprecatedTest {
  @Deprecated
  public void serve() {

  }

}
If you use or override a deprecated method, you will get a warning at compile time.
public class DeprecatedTest2 {
  public static void main(String[] args) {
    DeprecatedTest test = new DeprecatedTest();
    test.serve();
  }
}

class DeprecatedTest {
  @Deprecated
  public void serve() {

  }

}


No comments:

Post a Comment

Chitika