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

I declared private variables in the BlogPost class, but the error is telling me I didn't. What am I doing wrong?

Error Msg: "Bummer! Please add private member variables for author, title, body, category and creation date."

I declared variables for example: 'private String mAuthor', and the same for the other variables except date being of the Date type. I also made sure to import java.util.Date but that's not the error. There's no compiler errors so I'm thinking its a runtime error that it just not obvious to me.

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

public class BlogPost {
  private String mAuthor;
  private String mTitle;
  private String mCategory;
  private Date mDate;

  public BlogPost(String author, String title, String category, Date date) {
    mAuthor = author;
    mTitle = title;
    mCategory = category;
    mDate = date;
  }
}

1 Answer

Hello,

It looks like you're at least missing the member variable for the body.

Thanks James! That did it. I completely missed the 'body' variable. Doh!

You're welcome, glad I could help, good luck with the rest of the course.