Home arrow static arrow Java Programming [Archive] - what's all abt "static" ???
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - what's all abt "static" ???
This topic has 2 replies on 1 page.

Posts:23
Registered: 7/29/03
what's all abt "static" ???  
Jul 27, 2004 12:54 AM



 
Hi! All,

1)can any one spot exact difference in the performance of a method using 'static' and normal method.
what are the advantages & disadvantages.

2)What's the use of static method, static variable, static block and so on & what are it's de-merits?

3)What's the problem of using static - method, variable, (or) block - in an application wherein, the
application has sessions.

Thanks,in Advance.
 

Posts:49
Registered: 6/17/04
Re: what's all abt "static" ???  
Jul 27, 2004 1:03 AM (reply 1 of 2)



 
Well as far as I have learnt is that static methods are called first in the program exection for example the
'main' method of the program carries all the required instruction needed for prgram execution and then it branches it if required so 'main' is declared as a 'static' method so that It is called prior to any method in program execution.
I hope u understand this :o/
 

Posts:1,695
Registered: 1/13/04
Re: what's all abt "static" ???  
Jul 27, 2004 1:16 AM (reply 2 of 2)



 
Static entities (members, methods, etc.) are UNIQUE in a JVM runtime.
It means that they are (or can be) shared among all classes instanciated in the JVM session.
They have a unique (al)location in memory, so you only use this memory size, whatever the number
of object created instances is.
To access one of these entities, you don't need to create an object instance because the entity belongs
to the Class, not (only) to the objects.

On the other side, non-static entities are 'carried' with objects. Each object has its own set of them,
and of course they take more memory as the number of object instances grow.
To access one of these entities, you need to create an object instance, because the entity belongs
to the objects.

Hope this clears a little the subject for you,

Regards.
 
This topic has 2 replies on 1 page.