"Annotations": SJB Institute of Technology
"Annotations": SJB Institute of Technology
Project Presentation
On
“Annotations”
By
UMESH M
Asst. Prof.
class TestAnnotation1{
public static void main(String args[ ])
{
Dog a=new Dog();
a.eatSomething();
}
}
class TestAnnotation1{
public static void main(String args[ ])
{
Dog a=new Dog();
a.eatSomething();
}
}
class Animal
{
void eatSomething()
{ System.out.println("eating something"); }
}
class TestAnnotation1{
public static void main(String args[ ])
{
Dog a=new Dog();
a.eatSomething();
}
}
Output:Comple Time Error
10/22/2019 Dept of ISE, SJBIT 5
@Deprecated
class A{
void m( )
{ System.out.println("hello m") ;}
@Deprecated
void n( )
{ System.out.println("hello n");}
}
class TestAnnotation3{
public static void main(String args[ ])
{
A a=new A();
a.n();
}
}
At Compile Time:
Note: Test.java uses or overrides a deprecated API.
At Runtime:
hello n
10/22/2019 Dept of ISE, SJBIT 6
@SuppressWarnings
class DeprecatedTest
{
@Deprecated
public void Display()
{
System.out.println("Deprecatedtest display()");
}
}
public class SuppressWarningTest
{
// If we comment below annotation, program generates
// warning
@SuppressWarnings("deprecation")
public static void main(String args[])
{
DeprecatedTest d1 = new DeprecatedTest();
d1.Display();
}
}
10/22/2019 Dept of ISE, SJBIT 7
10/22/2019 Dept of ISE, SJBIT 8