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 Wrapping Up

Razvan Cirstea
Razvan Cirstea
2,493 Points

Can't solve the fourth task in the Forum challange

Hi,

I can't seem to figure out how to solve the fourth step in the code challange:

After you uncomment the code in Main.java and Forum.java, fix the code as described in the comments of Main.java. The code in main is attempting to use the code you just fixed.

'''java 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");
// TODO: pass in the first name and last name that are in the args parameter
User author = new User();
// TODO: initialize the forum post with the user created above and a title and description of your choice
ForumPost post = new ForumPost();
forum.addPost(post);

// */ }

} '''

1 Answer

Here is your answer

Forum forum = new Forum("Java");

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

ForumPost post = new ForumPost(author,"The title","The description");
forum.addPost(post);

This is the code I used, however it comes up with an error stating that it cannot find the "." symbol in forum.addPost(post);

Why is this?

./Main.java:15: 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