aspose file tools*
The moose likes Java in General and the fly likes Methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Methods" Watch "Methods" New topic
Author

Methods

Samer Memon
Greenhorn

Joined: Oct 25, 2001
Posts: 11
wht is the difference in static and non static methods in terms of memory.
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
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
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
Jane Griscti
Ranch Hand

Joined: Aug 30, 2000
Posts: 3141
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


Jane Griscti
SCJP, Co-author Mike Meyers' Java 2 Certification Passport
murali kante
Greenhorn

Joined: Nov 09, 2001
Posts: 9
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://aspose.com/file-tools
 
subject: Methods