Results 1 to 2 of 2

Thread: @ symbol?

  1. #1
    AgentSmith is offline Member
    Join Date
    Jun 2011
    Posts
    1
    Rep Power
    0

    Default @ symbol?

    When reviewing example code, I sometimes see the '@' symbol used as a prefix. For example, reading up on Java Web Services I seen the following in the code example:


    @WebServiceProvider

    @ServiceMode(value=Service.Mode.PAYLOAD)

    public class MyProvider implements Provider<Source> {
    public Source invoke(Source source) {
    String replyElement = new String("<p>hello world</p>");
    StreamSource reply = new StreamSource(
    new StringReader(replyElement));
    return reply;
    }
    ...


    Is the '@' symbol some pre-processing instruction?

    Thanks,
    AS

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,730
    Blog Entries
    7
    Rep Power
    21

    Default

    It's an annotation. The Java compiler employs so called annotation processors on them which can do (almost) what they want. Some annotations are understood by the compiler itself. Consider them a sort of "meta language".

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. inserting symbol
    By droidus in forum New To Java
    Replies: 5
    Last Post: 02-11-2011, 08:54 PM
  2. '@' Symbol
    By AedonetLIRA in forum New To Java
    Replies: 5
    Last Post: 12-09-2010, 02:05 AM
  3. cannot find symbol
    By GabWit in forum New To Java
    Replies: 3
    Last Post: 01-25-2009, 01:13 AM
  4. Replies: 9
    Last Post: 10-18-2008, 09:26 PM
  5. Replies: 3
    Last Post: 05-01-2008, 09:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •