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 trialRobert Zaharia
Courses Plus Student 579 PointsHi !I have to create a constructor with those parameters& I don't find the compilation error ! Can you help me ,please ?
...
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() );
2 Answers
Caleb Kleveter
Treehouse Moderator 37,862 PointsSteven 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;
}
Robert Zaharia
Courses Plus Student 579 PointsIt works. Thank you guys !
Steven Morimoto
Courses Plus Student 1,836 PointsSteven Morimoto
Courses Plus Student 1,836 PointsHi 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