@Deprecated
interface Kool {
// interface methods
} Deprecated class:@Deprecated
class Foo {
// class implementation
} class Bar {
@Deprecated
public void doSomethingWeird() {
// old method
}
public void doSomethingCool() {
// new, alternate method
}
} class Constant {
@Deprecated
public static final int MAX_SIZE = 1024;
// new, alternate field
public static final int MAX_UPLOAD_SIZE = 1024;
} class Car {
@Deprecated
Car(String color, int length, int width) {
}
// new, alternate constructor
Car(Style style) {
}
} Bar b = new Bar(); b.doSomethingWeird();
Note: Path\to\java\file.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details.
class MyCollection {
@Deprecated
public static final int DEFAULT_CAPACITY = 10;
private int initialCapacity = DEFAULT_CAPACITY;
} void getBytes(int srcBegin, int srcEnd, byte[] dst, int dstBegin)
Deprecated.
This method does not properly convert characters into bytes. As of JDK 1.1, the preferred way to do this is via the getBytes() method, which uses the platform's default charset.
Reference: How and When To Deprecate APIs
Nam Ha Minh is certified Java programmer (SCJP and SCWCD). He began programming with Java back in the days of Java 1.4 and has been passionate about it ever since. You can connect with him on Facebook and watch his Java videos on YouTube.