Java Java Data Structures Getting There Override an inherited method

Leo Marco Corpuz
Leo Marco Corpuz
18,975 Points

toString() and override method

What's wrong with my override code?

package com.example;

import java.util.Date;
import java.lang.Object;

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 toString(){
    return "Blogpost: "+ mTitle + " by " + mAuthor;

    public String getAuthor() {
      return mAuthor;

    public String getTitle() {
      return mTitle;

    public String getBody() {
      return mBody;

    public String getCategory() {
      return mCategory;

    public Date getCreationDate() {
      return mCreationDate;

2 Answers

your code is fine, it isn’t passing for u?

i did the same and it passed

You just have a small typo. It's BlogPost (capital P), not Blogpost. Hope this helps :)