r/javahelp • u/MembershipOptimal514 • May 07 '26
Codeless What does static exactly do?
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.
15
Upvotes
View all comments
Show parent comment
1
u/ChaiTRex May 09 '26
finaldoesn't actually mean that the value can't be changed, only that the variable can't be assigned to more than once (try it withfinal int[] xs = {0}; xs[0] = 1; System.out.println(xs[0]);).