-1

i have written code of custom deprecated annotation...if i run it in eclipse it didn't show compilation error and if program executed by cmd it gives deprecated error in it so my Question is that why eclipse do not show these?????`

package annotation;

public class customdeprecated 
{
    int basesalary=6000,ta=250,da=50;
    int bonus=500,salary;
    @Deprecated
void show_salary()          //now it's deprecated method
{
    salary=basesalary+ta+da;
    System.out.println(salary);
}
void display()
{
    salary=basesalary+ta+da+bonus;
    System.out.println(salary);
}
    public static void main(String[] args) 
    {
        customdeprecated c=new customdeprecated();      

c.show_salary();            //compile time error
        c.display();
    }
}     
ArK
  • 20,698
  • 67
  • 109
  • 136
Raj Mevada
  • 21
  • 12

1 Answers1

0

When a method is deprecated and used it is not an error, because you can still use it and it should work. A deprecated method means that it is not being supported any more, but you can still use it at your own risk. See this link for more information.

In your case, and to answer your question, Eclipse IS telling you that you are using a deprecated method, by putting a strikethrough line on the method you are using. See the answer in this question to understand why it is not sending the WARNING.

The compiler will send the warning if the deprecated method is in another class. The same thing happens when you compile through cmd.

Community
  • 1
  • 1
skw
  • 516
  • 7
  • 19