This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Static Objects Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic

Static Objects

Joseph Cho
Ranch Hand

Joined: Feb 19, 2012
Posts: 42
What is the best way to go about making a static class?

I know in C# you just declare the class static.. but In Java you cannot unless it's a subclass correct?

Also, if I declare a static reference to a class. I'm trying to wrap my head around this.. Does this mean whatever object the reference is pointed to, no matter what outside class makes an instance of the class holding the static object of another class.. it will always retain the same variables for that static class instance?
Jeff Verdegan

Joined: Jan 03, 2004
Posts: 6109

Duplicate. Locking.
Consider Paul's rocket mass heater.
subject: Static Objects
Similar Threads
Access an object via reference variable (or not)
private static Test monitor = new Test(); -- Static + Private Object Referenc
what really it mean's
Inner Class Methods