#java static keyword

19 messages · Page 1 of 1 (latest)

gilded dune
#

HI! I'm studying java and I'm at a not very advanced level, could someone explain to me clearly how the static keyword works?

flat caveBOT
#

This post has been reserved for your question.

Hey @gilded dune! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

half plover
#

these objects are created using classes.

#

you call methods with these objects that usually do certain work, such as updating the object's data etc.

#

when you say static you are telling java not to use an object

#

an example would be Math.abs(double a)

#

it's called in isolation of any particular object of the Math class

#

if it were non-static, I would be forced to use a Math object to call the method like this: Math math = new Math(); math.abs(-5.0);

gilded dune
#

Thanks! Could you give me a small example?

flat caveBOT
# gilded dune Thanks! Could you give me a small example?

If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.

half plover
#

no good

gilded dune
#

thanks

flat caveBOT
uneven wind
#

these are some resources on it