Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1036897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:46:43+00:00 2026-05-16T14:46:43+00:00

java.lang.annotation.ElementType : A program element type. The constants of this enumerated type provide a

  • 0

java.lang.annotation.ElementType:

A program element type. The constants of this enumerated type provide a simple classification of the declared elements in a Java program. These constants are used with the Target meta-annotation type to specify where it is legal to use an annotation type.

There are the following constants:

  • ANNOTATION_TYPE – Annotation type declaration
  • CONSTRUCTOR – Constructor declaration
  • FIELD – Field declaration (includes enum constants)
  • LOCAL_VARIABLE – Local variable declaration
  • METHOD – Method declaration
  • PACKAGE – Package declaration
  • PARAMETER – Parameter declaration
  • TYPE – Class, interface (including annotation type), or enum declaration

Can someone explain what each of them are (where they’d be annotated in actual code)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T14:46:43+00:00Added an answer on May 16, 2026 at 2:46 pm

    This summarizes the main ones:

    @CustomTypeAnnotation
    public class MyAnnotatedClass {
      @CustomFieldAnnotation
      private String foo;
    
      @CustomConstructorAnnotation
      public MyAnnotatedClass() {
      }
    
      @CustomMethodAnnotation
      public String bar(@CustomParameterAnnotation String str) {
        @CustomLocalVariableAnnotation String asdf = "asdf";
        return asdf + str;
      }
    }
    

    ANNOTATION_TYPE is an annotation on another annotation, like this:

    @CustomAnnotationTypeAnnotation
    public @interface SomeAnnotation {
      ..
    }
    

    Package is defined in a package-info.java file in the package, like this:

    @CustomPackageLevelAnnotation
    package com.some.package;
    
    import com.some.package.annotation.PackageLevelAnnotation;
    

    For more info on PACKAGE annotations see here and here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What is the purpose of these java.lang.annotation imports in this code? Why are they
Can anyone explain in a clear way the practical differences between the java.lang.annotation.RetentionPolicy constants
Please help me How I can resolved this problem. java.lang.IllegalArgumentException: already added: Ltwitter4j/Annotation; [2012-05-14
I defined an annotation as follows import java.lang.annotation.ElementType import java.lang.annotation.Inherited import java.lang.annotation.Retention import java.lang.annotation.RetentionPolicy
Exception in thread main java.lang.NullPointerException at Library.loadBooks(Library.java:179) at UseLibrary.main(UseLibrary.java:105) This error makes me crazy!
I am calling java.lang.Runtime.exec(...) but this seems to accept the command lines as an
i got java.lang.NullPointerException by using CrudRepository my project looks like this: strut2 action service
I'm getting: root cause java.lang.ClassNotFoundException: org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1701) org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1546) org.springframework.util.ClassUtils.forName(ClassUtils.java:258) org.springframework.beans.factory.support.AbstractBeanDefinition.resolve I searched the internet
Help! I'm getting this error when trying to connect using JAX-WS webservice call: java.lang.NoClassDefFoundError:
Here is a test class: import java.lang.annotation.Annotation; import java.lang.reflect.Method; public class TestAnnotations { @interface

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.