Monday, 15 March 2010

oop - What is best use of static in Java -


I read some comments by the developer on other threads regarding the use of static variables:

    < Li> This is the cost of memory: When we get out of the classroom, where they were defined / created, then what is the method of releasing memory captured by the stable variable?
  1. If you can not avoid using static last variable management in memory case.

I think the use of stable is against OOPs concepts, memory management is bad, to defeat the concept of incubation. If I use 5-6 static variables then its effect will be so big that I have to stop using it. Or could any of you guys tell me the real use of an object-oriented programming language in Java?

"post-text" itemprop = "text">

It costs memory: when we get out of class where they were defined / created

OK. The value of this memory is not exactly accurate if the point 1 -> all the variables captures still or otherwise memory.

After this, the difference between stable and example variable occurs when they unreachable (ready for GC) example level Examples of unreachable when you get out of your area, but with examples referenced by constant references, they clearly get access to not being set to null can do.

Therefore,

static object o = new object (); O = null;

The object does not contain memory if the null is not explicitly set on , the sensor that is defined, Until that happens, unless this happens, then o depends on the class loader who loads this class gets GCed (provided the reference is not saved).

By defeating the concept of the inception.

Fixed field defeat encusulation encapsulation does not allow access to basic structures basically. There may be many debates at this point, so I will not take it up.

If I use 5-6 stabilized variables then its effect will be so big that I have to stop using it

Again, this Comes below 1 point. Stable instead of design choice . In my opinion, use stable as a lost option.


No comments:

Post a Comment