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 Data Structures Getting There Class Review

Robert Zaharia
PLUS
Robert Zaharia
Courses Plus Student 579 Points

Hi !I have to create a constructor with those parameters& I don't find the compilation error ! Can you help me ,please ?

...

com/example/BlogPost.java
package com.example;
import java.util.Date;

public class BlogPost {
private String mAuthor;
  private String mTitle;
  private String mCategory;
  private String mBody;
  private Date mCreationDate;}
   BlogPost(String mAuthor , String mTitle , String mCategory,String mBody , new mCreationDate() );
Steven Morimoto
Steven Morimoto
Courses Plus Student 1,836 Points

Hi Robert,

What I'd try is first:

1) make the BlogPost constructor access modifier public ex. public BlogPost() 2) I'd then make the variables in the constructor's argument without the "m" ex. String Author, String Title, etc 3) in the parameter of the constructor, I'd then set the above variables = to their "m" counterparts ex. Author = mAuthor; Title = mTitle; etc

That's what I would do. Let me know if this works.

Good luck,

Steve

2 Answers

Caleb Kleveter
MOD
Caleb Kleveter
Treehouse Moderator 37,862 Points

Steven Morimoto was correct in his comment above. Here is what the constructor should look like:

public BlogPost(String author, String title, String category, String body, Date creationDate) {
    mAuthor = author;
    mTitle = title;
    mCategory = category;
    mBody = body;
    mCreationDate = creationDate;
}