When you don't want users to use a certain method anymore you can mark it "deprecated" so that they get a warning when they compile a program that uses this method. This is only a warning. (instead of removing your deprecated method, which would give a compilation error in the calling pgm).
You can test this for yourself by compiling the following examples :
The first example "Test.java" contains a deprecated method "doIt()".
The second example "TestDeprecated.java" uses this deprecated method.
Compiling "TestDeprecated.java" gives :
D:\test>javac TestDeprecated.java
Note: TestDeprecated.java uses or overrides a deprecated API.
Note: Recompile with -deprecation for details.
D:\test>javac -deprecation TestDeprecated.java
TestDeprecated.java:8: warning: doIt() in Test has been deprecated
test.doIt();
^
1 warning
D:\test>
=== Test.java ===
Code:
public class Test {
public Test() {
}
/**
* @deprecated
*/
public void doIt() {
System.out.println("Executing Test.doIt()");
}
public static void main(String args[]) {
Test test = new Test();
test.doIt();
}
}
=== TestDeprecated.java ===
Code:
public class TestDeprecated {
public TestDeprecated () {
}
public static void main(String args[]) {
Test test = new Test();
test.doIt();
}
}
==================================