• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to use this type of annotation  RSS feed

 
anand boob
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Retention(RetentionPolicy.RUNTIME)
@Target({java.lang.annotation.ElementType.METHOD})
@Documented
public static @interface DefaultStringValue
{
public abstract String value();
}


how do i use this annotation on a method??? also wat do d words static and abstract signify here?
 
Devaka Cooray
Marshal
Posts: 5650
765
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can simply use the annotation as below:

The keyword "static" is used here so you can use this annotation as an inner member of a particular class, it's just like what you do with static nested classes. And, the keyword "abstract" does nothing here. You can leave it.

Ps - Please use real words when posting.

Devaka
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Close, Devaka. The value() does not have a default value so it must be provided:
 
Devaka Cooray
Marshal
Posts: 5650
765
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh! My silly mistake
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!