Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Java Objects Delivering the MVP Forum

I'm litterally copying somones answer but I still get this weird error.

I've tried my own solution but I got this error. Afterwards I tried someone else's answer but I still get the error. This is the error.

./Main.java:16: error: cannot find symbol
    forum.addPost(post);
         ^
  symbol:   method addPost(ForumPost)
  location: variable forum of type Forum
Note: JavaTester.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error

It would be very nice if someone could help. Here's the code.

public class Main {

  public static void main(String[] args) {
    System.out.println("Beginning forum example");
    if (args.length < 2) {
      System.out.println("Usage: java Main <first name> <last name>");
      System.err.println("<first name> and <last name> are required");
      System.exit(1);
    }

    Forum forum = new Forum("Java");

  User author = new User(args[0],args[1]);

ForumPost post = new ForumPost(author, "TestTitle", "TestDesc");
    forum.addPost(post);





  }

}
Bryan Martinez
Bryan Martinez
2,227 Points

Hi i'm still learning but I'll give it a shot. Did you uncomment the addPost method in the Forum class? I think you might have forgotten to do this which is why you cannot access addPost. Please let me know if this was the issue. if not I can try some other things. Thanks

Hehe, thank you Bryan Martinez I actully forgot to uncomment the addPost method. xD

Bryan Martinez
Bryan Martinez
2,227 Points

No problem! Funny how many times the issue causing us a big headache in programming is just a simple mistake lol

Happy Coding!

Haha, that is so true. We just have to learn how to be thorough when we're coding. Once again thanks for the help.