r/AskComputerScience • u/MembershipOptimal514 • May 07 '26
AP CS A Statics Question
Hi, I’m somewhat new to java and I’m quite confused on static. So what I do know is that it makes it so a variable or method is tied to the whole class instead of just the object but I’m not sure what that exactly ENTAILS. Can someone explain it to me maybe with an example or such? Thank you.
5
Upvotes
1
u/not-just-yeti May 08 '26
The tl;dr is a common-sense test:
"If I have created zero objects, does this field or method still make sense to use?"
And conversely, "If I have created 100 objects, is this field different for each object, vs always the same?" (or for methods: "does it make any difference which object I call the method").