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

Ricard Taujenis
Ricard Taujenis
4,383 Points

Finally, please add a getter method for the body. You didn't think I was going to make you type them all out, did you?!

not qute shure whats an issue here have 8 errors poping up solely of the misplacing getter method?

com/example/BlogPost.java
package com.example;

import java.util.Date;

public class BlogPost {

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

2 Answers

Blake Larson
Blake Larson
13,014 Points
package com.example;

import java.util.Date;

public class BlogPost {

  private String mAuthor;
  private String mTitle;
  private String mBody;
  private String mCategory;
  private Date mCreationDate;
} // <-------------  This should be at the very bottom.
  public BlogPost (String author, String title, String body, String category, Date creationdate)  {
    mAuthor = author;
    mTitle = title;
    mBody = body;
    mCategory = category;
    mCreationDate = creationdate;
  }
public String getBody() 
{
return mBody;
}
  // <------------

This worked for me

package com.example;

import java.util.Date;

public class BlogPost {

  private String mAuthor;
  private String mTitle;
  private String mBody;
  private String mCategory;
  private Date mCreationDate;
} 
  public BlogPost (String author, String title, String body, String category, Date creationdate)  {
    mAuthor = author;
    mTitle = title;
    mBody = body;
    mCategory = category;
    mCreationDate = creationdate;
  }
  public String getBody() {  //Try to indent this line so that it is in the piblic class
     return mBody;  //Try to indent this so that it is in the getter
}  //Hope this helped :)