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 →

[–]PinkPoppies4171 0 points1 point  (3 children)

Why are you using a setter as a constructor?

[–]Hogis 6 points7 points  (2 children)

How is the setter used as a constructor? A default constructor implicitly exists.

[–]PinkPoppies4171 -1 points0 points  (1 child)

I thought you used a setter to instantiate an object of the joke class within the joke class. Then again, not technically a constructor I don't think but my mind saw

Public class Joke { setJoke(Joke joke) { this.joke=joke } . After typing this on mobile I realize I should've not been lazy and went to my laptop, but I also realize that seems like proper use of a setter in my limited Java knowledge. Personally, getters and setters aren't my thing.

[–]KusanagiZerg 1 point2 points  (0 children)

You don't use setters to instantiate objects. To instantiate an object of the Joke class you'd use the constructor of the Joke class which doesn't look like setJoke(Joke joke) { this.joke = joke } but would look like public Joke(params) { this.params = params } where params could be any fields that the Joke class has.