Annotation Example
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
*
* @author bhavesh
*/
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.TYPE)
public @interface NewAnnotation {
public String name();
public int myno() default 10;
}
// @Override and @NewAnnotaion usage example
class A
{
public void test()
{
// block of code
}
}
class B extends A
{
@Override
public void test()
{
//block of code
}
}
@NewAnnotation(name="ISTAR")
public class ClassAnnotationTest {
// block of code
//
}
Comments
Post a Comment