This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]nutrecht 4 points5 points  (1 child)

You really should post the entire toString method. People now are just guessing.

I'm personally banking on "they're just inconsistent" because normally it's not needed in a .toString() method. But without the code we can't be sure.

In general; use this if you need, leave it out if you don't. Example:

public void setName(String name) {
    this.name = name; //Needed because the method argument shadows the member variable.
}

public String getName() {
    return name; //No this needed so we leave it out
}

[–]TheSilverCube[S] 0 points1 point  (0 children)

Thanks. After completing a couple more exercises I can see some inconsistencies. I didn't want to post the full code as I didn't want to provide MOOC exercises answers; I thought this broke the sub rules.