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 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.