[JAVA] What is an annotation?

Introduction

This time about Java annotation. It's just a memo that you can easily organize the meaning and merits of annotations that you seem to know but don't know (?).

What is an annotation?

package hoge.nwobhm;
 
public class Metallica {
    @Override
    public String playMetal() {
        return "riff";
    }
    public static void main(String[] args) {
        Metallica metal= new Metallica ();
        System.out.println(metal.playMetal());
    }
}

For example, what is there?

Specifically, there are the following.

In addition, annotations are divided into three types.

    1. Marker: Name only, no data
  1. Single annotation: One that has one data
    1. Full annotation: Those with multiple data

Can I use only the fixed ones?

package hoge.nwobhm;

public @interface Megadeth {
    String value();
}

What are the benefits of using it?

reference

Recommended Posts

What is an annotation?
What is an interface?
What is an initializer?
What is an operator?
[Memorandum] What is an error?
What exactly is an API?
[Ruby] What is an instance?
What is Cubby
What is Docker?
What is null? ]
What is Keycloak
What is maven?
What is Jackson?
What is Docker
What is self
What is Jenkins
What is ArgumentMatcher?
What is params
What is SLF4J?
What is Facade? ??
What is Java <>?
What is Gradle?
What is POJO
What is Java
What is centOS
What is RubyGem?
What is programming?
What is before_action?
What is Docker
What is Byte?
What is Tomcat
What is Maven Assembly?
What is `docker-compose up`?
What is a constructor?
What is vue cli
What is Ruby's self?
What is hard coding?
What is a stream
What is Ruby's attr_accessor?
What is Java Encapsulation?
What is permission denied?
What is instance control?
What is Spring Tools 4
What is object orientation?
What is Guava's @VisibleForTesting?
What is Java technology?
What is Java API-java
What is @ (instance variable)?
What is Gradle's Artifact?
What is JPA Auditing?
[Swift] What is dismiss?
[Java] What is flatMap?
What is a Servlet?
What is web development?
[Java] What is JavaBeans?
[Android] What is Context? ??
[Java] What is ArrayList?
[Ruby] What is true?
What is object-oriented after all?
What is HttpSession session = request.getSession ();
What is docker run -it?