File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes static method vs instance method 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 » Beginning Java
Bookmark "static method vs instance method" Watch "static method vs instance method" New topic
Author

static method vs instance method

rahman habib
Greenhorn

Joined: May 20, 2007
Posts: 8
What is difference between static method and instance method.
which one one is better in terms of memory and performance.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39409
    
  28
Static methods have nothing to do with performance or memory management. They affect different things. A static member:
  • Is typed by the compiler
  • Is not polymorphic
  • Cannot be overridden, only hidden
  • Belongs to the class, not the object
  • There is only one copy of it per class
  • Every object of that class has access to the same static member
  • Static methods cannot access instance methods or instance fields.
  • camilo lopes
    Ranch Hand

    Joined: Aug 08, 2007
    Posts: 202
    all depend on of the your objective, but static method, this pertence the class and instance method pertence the an object, this do not have relation with a class.
    in terms of perfomance nothing change.


    Brazil - Sun Certified Java Programmer - SCJP 5
    http://www.camilolopes.com/ About Java - Update every Week.
    Guide SCJP - tips that you need know http://blog.camilolopes.com.br/livrosrevistaspalestras/
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: static method vs instance method