Originally posted by Samer Memon: wht is the difference in static and non static methods in terms of memory.
Nothing whatsoever. It's state (i.e. instance variables), not methods, that takes a certain amount of memory per object. - Peter
Samer Memon
Greenhorn
Joined: Oct 25, 2001
Posts: 11
posted
0
thanks peter. my question is still the same. ok not methods ,is there any difference in static and instance variables in terms of memory. Thanks in advance Samer
Hi Samer, Well, only one static variable will exist per class. With non-static variables you'll get one for every object created. The more objects you create, the more memory you use. Hope that helps. ------------------ Jane Griscti Sun Certified Programmer for the Java� 2 Platform
Well, think in terms of Design time (compile time ) and run time. The memory is allocated at run time for non static variables. Same with methods aswell. If u declare a method1()( in class A) as static and want to use this method in another class B, you dont need to create new Instance of A, u can directly say A.method1(). Hope this helps Murali
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.