Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialpratyush raj
7,097 Pointswhat is static in java???
can someone please explain me why we use static in java???
as far as i have understood like the example of pezdispenser where he declared: public final int MAX_PEZ=12; after that he expalined that if we do like this pezdispenser pd=new pezdispenser(); this will create a new object and we can access max_pez by pd.MAX_PEZ but if we make this : public static final int MAX_PEZ=12; we can directly access max_pez by the class name like pezdispenser.MAX_PEZ because max_pez is a constant we made it static and the class is also static so we got access of max_pez by class name.
i know i have explained it bit confusing but if anyone understood please tell me this am i saying it right or not ???