Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java Java Annotations Writing Your Own Annotation Putting It All Together

uday kiran
uday kiran
3,222 Points

Im getting issue while executing the last task

Getting Compile time error

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;

public @interface Test {

  String z() default "";
  String e()default "";

public class SocialNetworkTest {
  public void testTweet() {

  public void testInsta() { 


  public void testFacebook() { 

  public void testPinterest() { 

  public void testSnapchat() { 

import java.lang.reflect.Method;

public class TestAnalyzer {
   *  Counts the number of methods in the class given by `clazz` that have been annotated
   *  with the @Test annotation.
  public static int getNumAnnotatedMethods(Class<?> clazz) {

    Method[] methods = clazz.getDeclaredMethods();
    int result = 0;

    for (Method m : methods)
      if (m.isAnnotationPresent(SocialNetworkTest.class))

    return result;