• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

static method vs instance method

 
rahman habib
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is difference between static method and instance method.
which one one is better in terms of memory and performance.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49472
64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
    Posts: 202
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic