aspose file tools
The moose likes Beginning Java and the fly likes static method vs instance method Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Mongo DB Applied Patterns this week in the MongoDB forum
or a resume review from Five Year Itch in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply 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: 32599
    
    4
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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
     
    subject: static method vs instance method
     
    Similar Threads
    Reg. local variables
    same signature static + instance method
    Sttatic vs non static methods
    why static methods cannot override or overload?
    static method loading