package enumerations ;
import java.lang.annotation.Annotation ;
@interface my
{
char c () ;
double d () ;
}
// annotate a class
@my(c='f' , d =34.5 )
class cont implements e
{
int cc ;
}
interface e
{
}
public class annotations4
{
public static void main(String[] args)
{
cont q = new cont() ;
Annotation[] anno = q.getClass().getAnnotations() ;
System.out.println(anno.getClass());
System.out.println(anno);
// gives [Ljava.lang.annotation.Annotation;@4e25154f
e t ;
t = q ;
System.out.println(t);// gives enumerations.cont@70dea4e
}
}
I have some confusion here . When I print variable t which has return type of interface type e it gives the object type which is cont in the string . But when I print variable anno it just gives the return type which is the interface type Annotation .
What is the object type for variable anno ? Is there a way to find it ? Please help .
Aucun commentaire:
Enregistrer un commentaire