This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Methods

 
Samer Memon
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
wht is the difference in static and non static methods in terms of memory.
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3141
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
murali kante
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic