<pre lang="java"><pre lang="java">
I know that we cannot create an object of an interface .
Annotation e = new Annotation () ; // compile time error .
But I am confused about what happens in the following code .
Class c = ob.getClass() ; // ob is an object of a class created by us .
Annotation a[] = c.getAnnotations[] ;
// this returns an array of Annotation type but this is not an object of Annotation .
System.out.println ( a[0].hashCode() ) ; // or toString() method .
Which hashCode() method will run here ? I think it is not of class Object and can't be of the Annotation interface since Annotation's methods are abstract .
Is this method of a class which implements Annotation interface . But we haven't specified that class and there are many classes which implement Annotation interface .
Please someone explain this . I would be able to understand this if you provide in-depth explanation .Thanks .
What I have tried:
I tried to understand this through the documentation but got confused .