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

  • Home
  • SEARCH
  • 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 6329923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:46:02+00:00 2026-05-24T17:46:02+00:00

I want to create tree structure with annotation @Retention(RetentionPolicy.RUNTIME) public @interface MyNode { String

  • 0

I want to create tree structure with annotation

@Retention(RetentionPolicy.RUNTIME)
public @interface MyNode {
     String name();
     MyNode next() default null;
}

but compiler tells that it is cycle and hence it is not allowed.

I wonder why it is not allowed and how can I make something like it?

  • 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-24T17:46:03+00:00Added an answer on May 24, 2026 at 5:46 pm
    1. Annotations are compile-time constants.
    2. Annotation members can only be compile-time constants (Strings, primitives, enums, annotations, class literals).
    3. Anything that references itself can’t be a constant, so an annotation can’t reference itself.

    The funny thing is: there is a part of the Java Language specification that seems to contradict this:

    An annotation on an annotation type declaration is known as a
    meta-annotation. An annotation type may be used to annotate its own
    declaration. More generally, circularities in the transitive closure
    of the “annotates” relation are permitted. For example, it is legal to
    annotate an annotation type declaration with another annotation type,
    and to annotate the latter type’s declaration with the former type.
    (The pre-defined meta-annotation types contain several such
    circularities.)
    [Source]

    But I get a compile error for both this (annotation references itself):

    public @interface Funky {
        Funky funky();
    }
    

    and this (two annotations reference each other):

    public @interface Funky {
        Monkey monkey();
    }
    public @interface Monkey {
        Funky funky();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create tree structure using web service. I have used bottom up
I want to create binary search tree data structure in C/C++ where each node
Each item looks like this: public interface IEffect { string Name { get; }
I want to create an empty directory structure bar2 from a nonempty directory tree
I want to display a file tree similarly to java2s.com 'Create a lazy file
I have a tree structure in an sql table like so: CREATE TABLE containers
I want to create a completely generic treeview like structure. some thing like this:
I have the following structure: MyClass { guid ID guid ParentID string Name }
So I'm trying to create a tree structure in PHP. I don't know if
i have the below structure in HTML, which i use to create a tree

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.