#Meme explanation curious to know what's up with it

1 messages · Page 1 of 1 (latest)

autumn panther
#

Meme explain pwease...Iike there is a class meme with the private attribute Joke, Then within this class there is no constructor but directly a method called setJoke which takes a mesjoke as parameter and tf why does the method act as constructor here??

heavy ferryBOT
#

<@&987246399047479336> please have a look, thanks.

autumn panther
#

Meme explanation curious to know what's up with it

red reef
#

literally you can't get it

#

the method doesn't act as a constructor, that's how a setter works

#

the difference is

#

in a constructor you give the value in creation

#

in a setter you change the current value (no constructor, so default for objects is null)

flat zinc
#

We divide modifiers into two groups:

Access Modifiers - controls the access level
Non-Access Modifiers - do not control access level, but provides other functionality

#

So public code is accessible for all classes.

#

But private code is only accessible within the declared class.

#

So the private attribute Joke can't access directly.

#

In this case, we use setter and getter.

misty furnace
# red reef literally you can't get it

@autumn panther Not sure if you understood it, but that is the answer to your question.

The subtitle says "You wouldn't get it", which is funny because there's no way for you to get the joke instance from the object.
You would be able to set it, but not to get it.

formal turret