OVH Cloud OVH Cloud

Annotation probleme ...

1 réponse
Avatar
Vincent Cantin
Bonjour,

Je n'arrive pas a creer un type d'annotation ayant des champs.
Quelqu'un peu de me donner court example qui compile ?

moi j'ai (en gros) :

public @interface MonAnnotation
{
int a = 0;
int b = 1;
}

@MonAnnotation(a = 2, b = 3)
public class MaClasse
{
...
}

Mais le compilateur ne veut pas compiler, il me dit :

cannot find symbol; symbol : method a()

1 réponse

Avatar
Vincent Cantin
"Vincent Cantin" ¼¶¼g©ó¶l¥ó·s»D:
Bonjour,

Je n'arrive pas a creer un type d'annotation ayant des champs.
Quelqu'un peu de me donner court example qui compile ?

moi j'ai (en gros) :

public @interface MonAnnotation
{
int a = 0;
int b = 1;
}

@MonAnnotation(a = 2, b = 3)
public class MaClasse
{
...
}

Mais le compilateur ne veut pas compiler, il me dit :

cannot find symbol; symbol : method a()



J'ai trouve, il faut faire :

public @interface MonAnnotation
{
int a();
int b();
}